diff options
Diffstat (limited to 'include/linux/cpuset.h')
| -rw-r--r-- | include/linux/cpuset.h | 65 | 
1 files changed, 54 insertions, 11 deletions
diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h index a5740fc4d04..457ed765a11 100644 --- a/include/linux/cpuset.h +++ b/include/linux/cpuset.h @@ -21,8 +21,7 @@ extern int number_of_cpusets;	/* How many cpusets are defined in system? */  extern int cpuset_init(void);  extern void cpuset_init_smp(void);  extern void cpuset_cpus_allowed(struct task_struct *p, struct cpumask *mask); -extern void cpuset_cpus_allowed_locked(struct task_struct *p, -				       struct cpumask *mask); +extern int cpuset_cpus_allowed_fallback(struct task_struct *p);  extern nodemask_t cpuset_mems_allowed(struct task_struct *p);  #define cpuset_current_mems_allowed (current->mems_allowed)  void cpuset_init_current_mems_allowed(void); @@ -69,10 +68,8 @@ struct seq_file;  extern void cpuset_task_status_allowed(struct seq_file *m,  					struct task_struct *task); -extern void cpuset_lock(void); -extern void cpuset_unlock(void); -  extern int cpuset_mem_spread_node(void); +extern int cpuset_slab_spread_node(void);  static inline int cpuset_do_page_mem_spread(void)  { @@ -90,9 +87,44 @@ extern void rebuild_sched_domains(void);  extern void cpuset_print_task_mems_allowed(struct task_struct *p); +/* + * reading current mems_allowed and mempolicy in the fastpath must protected + * by get_mems_allowed() + */ +static inline void get_mems_allowed(void) +{ +	current->mems_allowed_change_disable++; + +	/* +	 * ensure that reading mems_allowed and mempolicy happens after the +	 * update of ->mems_allowed_change_disable. +	 * +	 * the write-side task finds ->mems_allowed_change_disable is not 0, +	 * and knows the read-side task is reading mems_allowed or mempolicy, +	 * so it will clear old bits lazily. +	 */ +	smp_mb(); +} + +static inline void put_mems_allowed(void) +{ +	/* +	 * ensure that reading mems_allowed and mempolicy before reducing +	 * mems_allowed_change_disable. +	 * +	 * the write-side task will know that the read-side task is still +	 * reading mems_allowed or mempolicy, don't clears old bits in the +	 * nodemask. +	 */ +	smp_mb(); +	--ACCESS_ONCE(current->mems_allowed_change_disable); +} +  static inline void set_mems_allowed(nodemask_t nodemask)  { +	task_lock(current);  	current->mems_allowed = nodemask; +	task_unlock(current);  }  #else /* !CONFIG_CPUSETS */ @@ -105,10 +137,11 @@ static inline void cpuset_cpus_allowed(struct task_struct *p,  {  	cpumask_copy(mask, cpu_possible_mask);  } -static inline void cpuset_cpus_allowed_locked(struct task_struct *p, -					      struct cpumask *mask) + +static inline int cpuset_cpus_allowed_fallback(struct task_struct *p)  { -	cpumask_copy(mask, cpu_possible_mask); +	cpumask_copy(&p->cpus_allowed, cpu_possible_mask); +	return cpumask_any(cpu_active_mask);  }  static inline nodemask_t cpuset_mems_allowed(struct task_struct *p) @@ -157,14 +190,16 @@ static inline void cpuset_task_status_allowed(struct seq_file *m,  {  } -static inline void cpuset_lock(void) {} -static inline void cpuset_unlock(void) {} -  static inline int cpuset_mem_spread_node(void)  {  	return 0;  } +static inline int cpuset_slab_spread_node(void) +{ +	return 0; +} +  static inline int cpuset_do_page_mem_spread(void)  {  	return 0; @@ -193,6 +228,14 @@ static inline void set_mems_allowed(nodemask_t nodemask)  {  } +static inline void get_mems_allowed(void) +{ +} + +static inline void put_mems_allowed(void) +{ +} +  #endif /* !CONFIG_CPUSETS */  #endif /* _LINUX_CPUSET_H */  |