Messages in this thread | | | Date | Wed, 31 Aug 2022 11:14:25 +0200 | From | Peter Zijlstra <> | Subject | Re: [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.
| |