diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2011-08-11 15:14:58 +0200 |
---|---|---|
committer | Clark Williams <williams@redhat.com> | 2012-03-13 12:40:05 -0500 |
commit | a59109692927be219a98bf52506949fb994e65dd (patch) | |
tree | 4b92859efed0e46c3eb0901b2ed16395a755eb30 /include | |
parent | c6f2cc7ac729d65cd1378e3167ff040464ab7f84 (diff) |
sched: Generic migrate_disable
Make migrate_disable() be a preempt_disable() for !rt kernels. This
allows generic code to use it but still enforces that these code
sections stay relatively small.
A preemptible migrate_disable() accessible for general use would allow
people growing arbitrary per-cpu crap instead of clean these things
up.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-275i87sl8e1jcamtchmehonm@git.kernel.org
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/preempt.h | 21 | ||||
-rw-r--r-- | include/linux/sched.h | 13 | ||||
-rw-r--r-- | include/linux/smp.h | 9 |
3 files changed, 24 insertions, 19 deletions
diff --git a/include/linux/preempt.h b/include/linux/preempt.h index 5aa7916e9a0d..6450c0113b5b 100644 --- a/include/linux/preempt.h +++ b/include/linux/preempt.h @@ -108,28 +108,25 @@ do { \ #endif /* CONFIG_PREEMPT_COUNT */ -#ifdef CONFIG_SMP -extern void migrate_disable(void); -extern void migrate_enable(void); -#else -# define migrate_disable() do { } while (0) -# define migrate_enable() do { } while (0) -#endif - #ifdef CONFIG_PREEMPT_RT_FULL # define preempt_disable_rt() preempt_disable() # define preempt_enable_rt() preempt_enable() # define preempt_disable_nort() do { } while (0) # define preempt_enable_nort() do { } while (0) -# define migrate_disable_rt() migrate_disable() -# define migrate_enable_rt() migrate_enable() +# ifdef CONFIG_SMP + extern void migrate_disable(void); + extern void migrate_enable(void); +# else /* CONFIG_SMP */ +# define migrate_disable() do { } while (0) +# define migrate_enable() do { } while (0) +# endif /* CONFIG_SMP */ #else # define preempt_disable_rt() do { } while (0) # define preempt_enable_rt() do { } while (0) # define preempt_disable_nort() preempt_disable() # define preempt_enable_nort() preempt_enable() -# define migrate_disable_rt() do { } while (0) -# define migrate_enable_rt() do { } while (0) +# define migrate_disable() preempt_disable() +# define migrate_enable() preempt_enable() #endif #ifdef CONFIG_PREEMPT_NOTIFIERS diff --git a/include/linux/sched.h b/include/linux/sched.h index 712e991a7436..32e9e3fd408c 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1259,7 +1259,9 @@ struct task_struct { #endif unsigned int policy; +#ifdef CONFIG_PREEMPT_RT_FULL int migrate_disable; +#endif cpumask_t cpus_allowed; #ifdef CONFIG_PREEMPT_RCU @@ -2681,11 +2683,22 @@ static inline void set_task_cpu(struct task_struct *p, unsigned int cpu) #endif /* CONFIG_SMP */ +static inline int __migrate_disabled(struct task_struct *p) +{ +#ifdef CONFIG_PREEMPT_RT_FULL + return p->migrate_disable; +#else + return 0; +#endif +} + /* Future-safe accessor for struct task_struct's cpus_allowed. */ static inline const struct cpumask *tsk_cpus_allowed(struct task_struct *p) { +#ifdef CONFIG_PREEMPT_RT_FULL if (p->migrate_disable) return cpumask_of(task_cpu(p)); +#endif return &p->cpus_allowed; } diff --git a/include/linux/smp.h b/include/linux/smp.h index 94c8430da063..78fd0a26fa05 100644 --- a/include/linux/smp.h +++ b/include/linux/smp.h @@ -172,13 +172,8 @@ smp_call_function_any(const struct cpumask *mask, smp_call_func_t func, #define get_cpu() ({ preempt_disable(); smp_processor_id(); }) #define put_cpu() preempt_enable() -#ifndef CONFIG_PREEMPT_RT_FULL -# define get_cpu_light() get_cpu() -# define put_cpu_light() put_cpu() -#else -# define get_cpu_light() ({ migrate_disable(); smp_processor_id(); }) -# define put_cpu_light() migrate_enable() -#endif +#define get_cpu_light() ({ migrate_disable(); smp_processor_id(); }) +#define put_cpu_light() migrate_enable() /* * Callback to arch code if there's nosmp or maxcpus=0 on the |