diff options
Diffstat (limited to 'kernel/sched.c')
-rw-r--r-- | kernel/sched.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/kernel/sched.c b/kernel/sched.c index 39d6354af489..72a809a54d5b 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -4471,8 +4471,21 @@ long sched_setaffinity(pid_t pid, cpumask_t new_mask) | |||
4471 | 4471 | ||
4472 | cpus_allowed = cpuset_cpus_allowed(p); | 4472 | cpus_allowed = cpuset_cpus_allowed(p); |
4473 | cpus_and(new_mask, new_mask, cpus_allowed); | 4473 | cpus_and(new_mask, new_mask, cpus_allowed); |
4474 | again: | ||
4474 | retval = set_cpus_allowed(p, new_mask); | 4475 | retval = set_cpus_allowed(p, new_mask); |
4475 | 4476 | ||
4477 | if (!retval) { | ||
4478 | cpus_allowed = cpuset_cpus_allowed(p); | ||
4479 | if (!cpus_subset(new_mask, cpus_allowed)) { | ||
4480 | /* | ||
4481 | * We must have raced with a concurrent cpuset | ||
4482 | * update. Just reset the cpus_allowed to the | ||
4483 | * cpuset's cpus_allowed | ||
4484 | */ | ||
4485 | new_mask = cpus_allowed; | ||
4486 | goto again; | ||
4487 | } | ||
4488 | } | ||
4476 | out_unlock: | 4489 | out_unlock: |
4477 | put_task_struct(p); | 4490 | put_task_struct(p); |
4478 | mutex_unlock(&sched_hotcpu_mutex); | 4491 | mutex_unlock(&sched_hotcpu_mutex); |