Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit df14b7f

Browse files
Waiman-LongPeter Zijlstra
authored andcommitted
sched/core: Fix a missed update of user_cpus_ptr
Since commit 8f9ea86 ("sched: Always preserve the user requested cpumask"), a successful call to sched_setaffinity() should always save the user requested cpu affinity mask in a task's user_cpus_ptr. However, when the given cpu mask is the same as the current one, user_cpus_ptr is not updated. Fix this by saving the user mask in this case too. Fixes: 8f9ea86 ("sched: Always preserve the user requested cpumask") Signed-off-by: Waiman Long <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent eedeb78 commit df14b7f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

kernel/sched/core.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2951,8 +2951,11 @@ static int __set_cpus_allowed_ptr_locked(struct task_struct *p,
29512951
}
29522952

29532953
if (!(ctx->flags & SCA_MIGRATE_ENABLE)) {
2954-
if (cpumask_equal(&p->cpus_mask, ctx->new_mask))
2954+
if (cpumask_equal(&p->cpus_mask, ctx->new_mask)) {
2955+
if (ctx->flags & SCA_USER)
2956+
swap(p->user_cpus_ptr, ctx->user_mask);
29552957
goto out;
2958+
}
29562959

29572960
if (WARN_ON_ONCE(p == current &&
29582961
is_migration_disabled(p) &&

0 commit comments

Comments
 (0)