Skip to content
/ linux Public
forked from torvalds/linux

Commit

Permalink
sched/core: Fix a missed update of user_cpus_ptr
Browse files Browse the repository at this point in the history
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]
  • Loading branch information
Waiman-Long authored and Peter Zijlstra committed Feb 13, 2023
1 parent eedeb78 commit df14b7f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion kernel/sched/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2951,8 +2951,11 @@ static int __set_cpus_allowed_ptr_locked(struct task_struct *p,
}

if (!(ctx->flags & SCA_MIGRATE_ENABLE)) {
if (cpumask_equal(&p->cpus_mask, ctx->new_mask))
if (cpumask_equal(&p->cpus_mask, ctx->new_mask)) {
if (ctx->flags & SCA_USER)
swap(p->user_cpus_ptr, ctx->user_mask);
goto out;
}

if (WARN_ON_ONCE(p == current &&
is_migration_disabled(p) &&
Expand Down

0 comments on commit df14b7f

Please sign in to comment.