1 #ifndef __LINUX_PREEMPT_H
2 #define __LINUX_PREEMPT_H
10 #include <linux/linkage.h>
11 #include <linux/list.h>
13 #if defined(CONFIG_DEBUG_PREEMPT) || defined(CONFIG_PREEMPT_TRACER)
17 # define add_preempt_count(val) do { preempt_count() += (val); } while (0)
18 # define sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
21 #define inc_preempt_count() add_preempt_count(1)
22 #define dec_preempt_count() sub_preempt_count(1)
24 #define preempt_count() (current_thread_info()->preempt_count)
30 #define preempt_check_resched() \
32 if (unlikely(test_thread_flag(TIF_NEED_RESCHED))) \
38 #define preempt_check_resched() do { } while (0)
43 #ifdef CONFIG_PREEMPT_COUNT
45 #define preempt_disable() \
47 inc_preempt_count(); \
51 #define sched_preempt_enable_no_resched() \
54 dec_preempt_count(); \
57 #define preempt_enable_no_resched() sched_preempt_enable_no_resched()
59 #define preempt_enable() \
61 preempt_enable_no_resched(); \
63 preempt_check_resched(); \
67 #define add_preempt_count_notrace(val) \
68 do { preempt_count() += (val); } while (0)
69 #define sub_preempt_count_notrace(val) \
70 do { preempt_count() -= (val); } while (0)
71 #define inc_preempt_count_notrace() add_preempt_count_notrace(1)
72 #define dec_preempt_count_notrace() sub_preempt_count_notrace(1)
74 #define preempt_disable_notrace() \
76 inc_preempt_count_notrace(); \
80 #define preempt_enable_no_resched_notrace() \
83 dec_preempt_count_notrace(); \
87 #define preempt_enable_notrace() \
89 preempt_enable_no_resched_notrace(); \
91 preempt_check_resched(); \
96 #define preempt_disable() do { } while (0)
97 #define sched_preempt_enable_no_resched() do { } while (0)
98 #define preempt_enable_no_resched() do { } while (0)
99 #define preempt_enable() do { } while (0)
101 #define preempt_disable_notrace() do { } while (0)
102 #define preempt_enable_no_resched_notrace() do { } while (0)
103 #define preempt_enable_notrace() do { } while (0)
107 #ifdef CONFIG_PREEMPT_NOTIFIERS
109 struct preempt_notifier;
126 void (*sched_in)(
struct preempt_notifier *notifier,
int cpu);
127 void (*sched_out)(
struct preempt_notifier *notifier,
138 struct preempt_notifier {
140 struct preempt_ops *
ops;
143 void preempt_notifier_register(
struct preempt_notifier *notifier);
144 void preempt_notifier_unregister(
struct preempt_notifier *notifier);
146 static inline void preempt_notifier_init(
struct preempt_notifier *notifier,
147 struct preempt_ops *ops)
149 INIT_HLIST_NODE(¬ifier->link);