aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/hardirq.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/hardirq.h')
-rw-r--r--include/linux/hardirq.h18
1 files changed, 10 insertions, 8 deletions
diff --git a/include/linux/hardirq.h b/include/linux/hardirq.h
index 897f723bd222..181006cc94a0 100644
--- a/include/linux/hardirq.h
+++ b/include/linux/hardirq.h
@@ -72,6 +72,14 @@
72#define in_softirq() (softirq_count()) 72#define in_softirq() (softirq_count())
73#define in_interrupt() (irq_count()) 73#define in_interrupt() (irq_count())
74 74
75#if defined(CONFIG_PREEMPT)
76# define PREEMPT_INATOMIC_BASE kernel_locked()
77# define PREEMPT_CHECK_OFFSET 1
78#else
79# define PREEMPT_INATOMIC_BASE 0
80# define PREEMPT_CHECK_OFFSET 0
81#endif
82
75/* 83/*
76 * Are we running in atomic context? WARNING: this macro cannot 84 * Are we running in atomic context? WARNING: this macro cannot
77 * always detect atomic context; in particular, it cannot know about 85 * always detect atomic context; in particular, it cannot know about
@@ -79,17 +87,11 @@
79 * used in the general case to determine whether sleeping is possible. 87 * used in the general case to determine whether sleeping is possible.
80 * Do not use in_atomic() in driver code. 88 * Do not use in_atomic() in driver code.
81 */ 89 */
82#define in_atomic() ((preempt_count() & ~PREEMPT_ACTIVE) != 0) 90#define in_atomic() ((preempt_count() & ~PREEMPT_ACTIVE) != PREEMPT_INATOMIC_BASE)
83
84#ifdef CONFIG_PREEMPT
85# define PREEMPT_CHECK_OFFSET 1
86#else
87# define PREEMPT_CHECK_OFFSET 0
88#endif
89 91
90/* 92/*
91 * Check whether we were atomic before we did preempt_disable(): 93 * Check whether we were atomic before we did preempt_disable():
92 * (used by the scheduler) 94 * (used by the scheduler, *after* releasing the kernel lock)
93 */ 95 */
94#define in_atomic_preempt_off() \ 96#define in_atomic_preempt_off() \
95 ((preempt_count() & ~PREEMPT_ACTIVE) != PREEMPT_CHECK_OFFSET) 97 ((preempt_count() & ~PREEMPT_ACTIVE) != PREEMPT_CHECK_OFFSET)