Re: PROBLEM: in_atomic() misuse all over the place

From: Andrew Morton
Date: Fri Jan 30 2009 - 19:04:08 EST


On Wed, 28 Jan 2009 13:18:50 +0100
Andi Kleen <andi@xxxxxxxxxxxxxx> wrote:

> > 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.
>

There's a bit of a problem here. If someone accidentally uses
gfp_any() inside a spinlock, it will do a sleeping allocation on
non-preempt kernels and will do an atomic allocation on preemptible
kernels, so we won't get to see the warning which would allow us to fix
the bug.

Would using irq_count() work? If so, that would fix this up.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/