lkml.org 
[lkml]   [2008]   [Mar]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: use of preempt_count instead of in_atomic() at leds-gpio.c
On Mon, 24 Mar 2008 13:34:49 -0600
corbet@lwn.net (Jonathan Corbet) wrote:

> Discourage people from using in_atomic()
>
> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
>
> diff --git a/include/linux/hardirq.h b/include/linux/hardirq.h
> index 4982998..3d196cb 100644
> --- a/include/linux/hardirq.h
> +++ b/include/linux/hardirq.h
> @@ -72,6 +72,11 @@
> #define in_softirq() (softirq_count())
> #define in_interrupt() (irq_count())
>
> +/*
> + * Are we running in atomic context? WARNING: this macro cannot
> + * always detect atomic context and should not be used to determine
> + * whether sleeping is possible. Do not use it in driver code.
> + */
> #define in_atomic() ((preempt_count() & ~PREEMPT_ACTIVE) != 0)

It'd be better if the comment were to describe _why_ in_atomic() is
unreliable. ie: "does not account for held spinlocks on non-preemptible
kernels".



\
 
 \ /
  Last update: 2008-03-24 20:45    [W:0.098 / U:1.424 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site