public inbox for linux-kernel@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.

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

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-27 23:10 PROBLEM: in_atomic() misuse all over the place Roger Larsson
2009-01-28  0:12 ` Robert Hancock
2009-01-31 11:45   ` Joerg Roedel
2009-01-28 12:18 ` Andi Kleen [this message]
2009-01-31  0:03   ` 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
2009-02-04 16:17 ` Pavel Machek

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.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=netdev@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=rml@tech9.net \
    --cc=roger.larsson@e-gatan.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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