aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2013-08-14 08:55:24 -0400
committerIngo Molnar <mingo@kernel.org>2013-09-25 08:07:32 -0400
commit4a2b4b222743bb07fedf985b884550f2ca067ea9 (patch)
tree587e80512c6cdf727b27d0f806758833547a65ed /include
parentea8117478918a4734586d35ff530721b682425be (diff)
sched: Introduce preempt_count accessor functions
Replace the single preempt_count() 'function' that's an lvalue with two proper functions: preempt_count() - returns the preempt_count value as rvalue preempt_count_set() - Allows setting the preempt-count value Also provide preempt_count_ptr() as a convenience wrapper to implement all modifying operations. Signed-off-by: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/n/tip-orxrbycjozopqfhb4dxdkdvb@git.kernel.org [ Fixed build failure. ] Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/preempt.h25
1 files changed, 19 insertions, 6 deletions
diff --git a/include/linux/preempt.h b/include/linux/preempt.h
index f5d4723cdb3d..eaac52a8fe6a 100644
--- a/include/linux/preempt.h
+++ b/include/linux/preempt.h
@@ -10,19 +10,32 @@
10#include <linux/linkage.h> 10#include <linux/linkage.h>
11#include <linux/list.h> 11#include <linux/list.h>
12 12
13static __always_inline int preempt_count(void)
14{
15 return current_thread_info()->preempt_count;
16}
17
18static __always_inline int *preempt_count_ptr(void)
19{
20 return &current_thread_info()->preempt_count;
21}
22
23static __always_inline void preempt_count_set(int pc)
24{
25 *preempt_count_ptr() = pc;
26}
27
13#if defined(CONFIG_DEBUG_PREEMPT) || defined(CONFIG_PREEMPT_TRACER) 28#if defined(CONFIG_DEBUG_PREEMPT) || defined(CONFIG_PREEMPT_TRACER)
14 extern void add_preempt_count(int val); 29 extern void add_preempt_count(int val);
15 extern void sub_preempt_count(int val); 30 extern void sub_preempt_count(int val);
16#else 31#else
17# define add_preempt_count(val) do { preempt_count() += (val); } while (0) 32# define add_preempt_count(val) do { *preempt_count_ptr() += (val); } while (0)
18# define sub_preempt_count(val) do { preempt_count() -= (val); } while (0) 33# define sub_preempt_count(val) do { *preempt_count_ptr() -= (val); } while (0)
19#endif 34#endif
20 35
21#define inc_preempt_count() add_preempt_count(1) 36#define inc_preempt_count() add_preempt_count(1)
22#define dec_preempt_count() sub_preempt_count(1) 37#define dec_preempt_count() sub_preempt_count(1)
23 38
24#define preempt_count() (current_thread_info()->preempt_count)
25
26#ifdef CONFIG_PREEMPT 39#ifdef CONFIG_PREEMPT
27 40
28asmlinkage void preempt_schedule(void); 41asmlinkage void preempt_schedule(void);
@@ -81,9 +94,9 @@ do { \
81 94
82/* For debugging and tracer internals only! */ 95/* For debugging and tracer internals only! */
83#define add_preempt_count_notrace(val) \ 96#define add_preempt_count_notrace(val) \
84 do { preempt_count() += (val); } while (0) 97 do { *preempt_count_ptr() += (val); } while (0)
85#define sub_preempt_count_notrace(val) \ 98#define sub_preempt_count_notrace(val) \
86 do { preempt_count() -= (val); } while (0) 99 do { *preempt_count_ptr() -= (val); } while (0)
87#define inc_preempt_count_notrace() add_preempt_count_notrace(1) 100#define inc_preempt_count_notrace() add_preempt_count_notrace(1)
88#define dec_preempt_count_notrace() sub_preempt_count_notrace(1) 101#define dec_preempt_count_notrace() sub_preempt_count_notrace(1)
89 102