make select_fallback_rq() cpuset friendly
PATCH 6/6 make select_fallback_rq() cpuset friendly
Introduce cpuset_cpus_allowed_fallback() helper to fix the cpuset problems with select_fallback_rq(). It can be called from any context and can't use any cpuset locks including task_lock(). It is called when the task doesn't have online cpus in ->cpus_allowed but ttwu/etc must be able to find a suitable cpu.
I am not proud of this patch. Everything which needs such a fact comment can't be good even if correct. But I'd prefer to not change the locking rules in the code I hardly understand, and in any case I believe this simple change make the code much more correct compared to deadlocks we currently have.
---
include/linux/cpuset.h | 7 +++++++ kernel/sched.c | 4 +--- kernel/cpuset.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 3 deletions(-)
include/linux/cpuset.h renamed from include/linux/cpuset.h~6_FALLBACK_CPUSETS +7 -0
@@ -21,6 +21,7 @@ extern int number_of_cpusets; /* How manextern int cpuset_init (void );extern void cpuset_init_smp (void );extern void cpuset_cpus_allowed (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 );
@@ -101,6 +102,12 @@ static inline void cpuset_cpus_allowed(scpumask_copy (mask, cpu_possible_mask); } +static inline int cpuset_cpus_allowed_fallback (struct task_struct *p) +{ +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) {return node_possible_map;
kernel/sched.c renamed from kernel/sched.c~6_FALLBACK_CPUSETS +1 -3
@@ -2292,9 +2292,7 @@ static int select_fallback_rq(int cpu, s/* No more Mr. Nice Guy. */ if (unlikely (dest_cpu >= nr_cpu_ids)) { -cpumask_copy (&p->cpus_allowed, cpu_possible_mask); - dest_cpu =cpumask_any (cpu_active_mask); - + dest_cpu =cpuset_cpus_allowed_fallback (p);/* * Don't tell them about moving exiting tasks or * kernel threads (both mm NULL), since they never
kernel/cpuset.c renamed from kernel/cpuset.c~6_FALLBACK_CPUSETS +42 -0
48 lines not on this page · raw message
[tip:sched/core] sched: Make select_fallback_rq() cpuset friendly
Commit-ID: 9084bb8246ea935b98320554229e2f371f7f52fa Gitweb: http://git.kernel.org/tip/9084bb8246ea935b98320554229e2f371f7f52fa Author: Oleg Nesterov <[email protected]> AuthorDate: Mon, 15 Mar 2010 10:10:27 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 2 Apr 2010 20:12:03 +0200
sched: Make select_fallback_rq() cpuset friendly
Introduce cpuset_cpus_allowed_fallback() helper to fix the cpuset problems with select_fallback_rq(). It can be called from any context and can't use any cpuset locks including task_lock(). It is called when the task doesn't have online cpus in ->cpus_allowed but ttwu/etc must be able to find a suitable cpu.
I am not proud of this patch. Everything which needs such a fat comment can't be good even if correct. But I'd prefer to not change the locking rules in the code I hardly understand, and in any case I believe this simple change make the code much more correct compared to deadlocks we currently have.
LKML-Reference: <[email protected]>
--- include/linux/cpuset.h | 7 +++++++ kernel/cpuset.c | 42 ++++++++++++++++++++++++++++++++++++++++++ kernel/sched.c | 4 +--- 3 files changed, 50 insertions(+), 3 deletions(-)
include/linux/cpuset.h +7 -0
@@ -21,6 +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 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 );
@@ -101,6 +102,12 @@ static inline void cpuset_cpus_allowed(struct task_struct *p,cpumask_copy (mask, cpu_possible_mask); } +static inline int cpuset_cpus_allowed_fallback (struct task_struct *p) +{ +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) {return node_possible_map;
kernel/cpuset.c +42 -0
48 lines not on this page · raw message
kernel/sched.c +1 -3
@@ -2300,9 +2300,7 @@ static int select_fallback_rq(int cpu, struct task_struct *p)/* No more Mr. Nice Guy. */ if (unlikely (dest_cpu >= nr_cpu_ids)) { -cpumask_copy (&p->cpus_allowed, cpu_possible_mask); - dest_cpu =cpumask_any (cpu_active_mask); - + dest_cpu =cpuset_cpus_allowed_fallback (p);/* * Don't tell them about moving exiting tasks or * kernel threads (both mm NULL), since they never