Skip to content

Commit

Permalink
in_atomic(): document why it is unsuitable for general use
Browse files Browse the repository at this point in the history
Discourage people from inappropriately using in_atomic()

Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Jonathan Corbet authored and Linus Torvalds committed Mar 28, 2008
1 parent f67e74c commit 8c703d3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/linux/hardirq.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@
#define in_softirq() (softirq_count())
#define in_interrupt() (irq_count())

/*
* Are we running in atomic context? WARNING: this macro cannot
* always detect atomic context; in particular, it cannot know about
* held spinlocks in non-preemptible kernels. Thus it should not be
* used in the general case to determine whether sleeping is possible.
* Do not use in_atomic() in driver code.
*/
#define in_atomic() ((preempt_count() & ~PREEMPT_ACTIVE) != 0)

#ifdef CONFIG_PREEMPT
Expand Down

0 comments on commit 8c703d3

Please sign in to comment.