]> Git Repo - linux.git/commitdiff
sched: Always clear user_cpus_ptr in do_set_cpus_allowed()
authorWaiman Long <[email protected]>
Thu, 22 Sep 2022 18:00:41 +0000 (14:00 -0400)
committerPeter Zijlstra <[email protected]>
Thu, 27 Oct 2022 09:01:22 +0000 (11:01 +0200)
The do_set_cpus_allowed() function is used by either kthread_bind() or
select_fallback_rq(). In both cases the user affinity (if any) should be
destroyed too.

Suggested-by: Peter Zijlstra <[email protected]>
Signed-off-by: Waiman Long <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
kernel/sched/core.c

index 283bdbd8c3c1cddb06416e4ea644e24ddfffe8f9..87c9cdf37a269879f942ff875b5784da002940d4 100644 (file)
@@ -2593,14 +2593,20 @@ __do_set_cpus_allowed(struct task_struct *p, struct affinity_context *ctx)
                set_next_task(rq, p);
 }
 
+/*
+ * Used for kthread_bind() and select_fallback_rq(), in both cases the user
+ * affinity (if any) should be destroyed too.
+ */
 void do_set_cpus_allowed(struct task_struct *p, const struct cpumask *new_mask)
 {
        struct affinity_context ac = {
                .new_mask  = new_mask,
-               .flags     = 0,
+               .user_mask = NULL,
+               .flags     = SCA_USER,  /* clear the user requested mask */
        };
 
        __do_set_cpus_allowed(p, &ac);
+       kfree(ac.user_mask);
 }
 
 int dup_user_cpus_ptr(struct task_struct *dst, struct task_struct *src,
This page took 0.104517 seconds and 4 git commands to generate.