lkml.org 
[lkml]   [2022]   [Aug]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v6 3/5] sched: Enforce user requested affinity
On Thu, Aug 25, 2022 at 09:01:17PM -0400, Waiman Long wrote:

> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index ac2b103d69dc..1c2f548e5369 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -2928,11 +2928,40 @@ static int __set_cpus_allowed_ptr_locked(struct task_struct *p,
> static int __set_cpus_allowed_ptr(struct task_struct *p,
> const struct cpumask *new_mask, u32 flags)
> {
> + struct cpumask *alloc_mask = NULL;
> struct rq_flags rf;
> struct rq *rq;
> + int ret;
>
> rq = task_rq_lock(p, &rf);
> - return __set_cpus_allowed_ptr_locked(p, new_mask, flags, rq, &rf);
> + if (p->user_cpus_ptr) {
> +
> + /*
> + * A scratch cpumask is allocated on the percpu runqueues
> + * to enable additional masking with user_cpus_ptr. This
> + * cpumask, once allocated, will not be freed.
> + */
> + if (unlikely(!rq->scratch_mask)) {
> + alloc_mask = kmalloc(cpumask_size(), GFP_ATOMIC);

This -- absolutely not. You can't have allocations under a
raw_spinlock_t.

\
 
 \ /
  Last update: 2022-08-31 11:15    [W:0.088 / U:0.552 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site