Skip to content

Commit 70ee794

Browse files
joshdonPeter Zijlstra
authored and
Peter Zijlstra
committed
sched: fix warning in sched_setaffinity
Commit 8f9ea86 added some logic to sched_setaffinity that included a WARN when a per-task affinity assignment races with a cpuset update. Specifically, we can have a race where a cpuset update results in the task affinity no longer being a subset of the cpuset. That's fine; we have a fallback to instead use the cpuset mask. However, we have a WARN set up that will trigger if the cpuset mask has no overlap at all with the requested task affinity. This shouldn't be a warning condition; its trivial to create this condition. Reproduced the warning by the following setup: - $PID inside a cpuset cgroup - another thread repeatedly switching the cpuset cpus from 1-2 to just 1 - another thread repeatedly setting the $PID affinity (via taskset) to 2 Fixes: 8f9ea86 ("sched: Always preserve the user requested cpumask") Signed-off-by: Josh Don <[email protected]> Acked-and-tested-by: Vincent Guittot <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Waiman Long <[email protected]> Tested-by: Madadi Vineeth Reddy <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 22368fe commit 70ee794

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/sched/syscalls.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,7 @@ int __sched_setaffinity(struct task_struct *p, struct affinity_context *ctx)
12001200
bool empty = !cpumask_and(new_mask, new_mask,
12011201
ctx->user_mask);
12021202

1203-
if (WARN_ON_ONCE(empty))
1203+
if (empty)
12041204
cpumask_copy(new_mask, cpus_allowed);
12051205
}
12061206
__set_cpus_allowed_ptr(p, ctx);

0 commit comments

Comments
 (0)