public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor•org>
To: Roger Larsson <roger.larsson@e-gatan•se>
Cc: linux-kernel@vger•kernel.org, Ingo Molnar <mingo@elte•hu>,
	Robert Love <rml@tech9•net>, Pavel Machek <pavel@ucw•cz>,
	netdev@vger•kernel.org
Subject: Re: PROBLEM: in_atomic() misuse all over the place
Date: Wed, 28 Jan 2009 13:18:50 +0100	[thread overview]
Message-ID: <87pri7k4id.fsf@basil.nowhere.org> (raw)
In-Reply-To: <200901280010.37633.roger.larsson@e-gatan.se> (Roger Larsson's message of "Wed, 28 Jan 2009 00:10:37 +0100")

Roger Larsson <roger.larsson@e-gatan•se> writes:

[cc netdev since network code is discussed]

> [2.] Full description of the problem/report:
>
> The problem is that in_atomic() only works on preemptive kernels...

That's not fully correct. It works in tasklets/softirqs/spin_lock_bh
on all kernels.

> file:  include/net/sock.h
>
>    static inline gfp_t gfp_any(void)
>    {
>      return in_atomic() ? GFP_ATOMIC : GFP_KERNEL;
>    }

That's typically for softirq vs non softirq, which is important
for the network stack.

That said its undoubtedly possible that some users get
it wrong and assume it applies to spinlocks (without _bh) too. 
But at least the classical uses in the network stack should be ok.

I personally would consider anyone using it inside a normal
spinlock dubious anyways, because GFP_ATOMIC is the wrong
thing to use here. The correct way is to either switch to a mutex/sem
or move the allocation outside the lock.

-Andi

-- 
ak@linux•intel.com -- Speaking for myself only.

       reply	other threads:[~2009-01-28 12:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200901280010.37633.roger.larsson@e-gatan.se>
2009-01-28 12:18 ` Andi Kleen [this message]
2009-01-31  0:03   ` PROBLEM: in_atomic() misuse all over the place Andrew Morton
2009-01-31  5:55     ` Andi Kleen
2009-01-31  5:49       ` Andrew Morton
2009-01-31  8:48         ` David Miller
2009-01-31  8:58           ` Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pri7k4id.fsf@basil.nowhere.org \
    --to=andi@firstfloor$(echo .)org \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=mingo@elte$(echo .)hu \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=pavel@ucw$(echo .)cz \
    --cc=rml@tech9$(echo .)net \
    --cc=roger.larsson@e-gatan$(echo .)se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox