lkml.org 
[lkml]   [2022]   [Sep]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v10 5/5] sched: Always clear user_cpus_ptr in do_set_cpus_allowed()
    Date
    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 <peterz@infradead.org>
    Signed-off-by: Waiman Long <longman@redhat.com>
    ---
    kernel/sched/core.c | 8 +++++++-
    1 file changed, 7 insertions(+), 1 deletion(-)

    diff --git a/kernel/sched/core.c b/kernel/sched/core.c
    index ce626cad4105..a5240c603667 100644
    --- a/kernel/sched/core.c
    +++ b/kernel/sched/core.c
    @@ -2599,14 +2599,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,
    --
    2.31.1
    \
     
     \ /
      Last update: 2022-09-22 20:02    [W:3.247 / U:0.540 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site