[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Yw8mcbgYThZGpMfN@hirez.programming.kicks-ass.net>
Date: Wed, 31 Aug 2022 11:14:25 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Waiman Long <longman@...hat.com>
Cc: Ingo Molnar <mingo@...hat.com>, Juri Lelli <juri.lelli@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Steven Rostedt <rostedt@...dmis.org>,
Ben Segall <bsegall@...gle.com>, Mel Gorman <mgorman@...e.de>,
Daniel Bristot de Oliveira <bristot@...hat.com>,
Valentin Schneider <vschneid@...hat.com>,
Tejun Heo <tj@...nel.org>, Zefan Li <lizefan.x@...edance.com>,
Johannes Weiner <hannes@...xchg.org>,
Will Deacon <will@...nel.org>, linux-kernel@...r.kernel.org,
Linus Torvalds <torvalds@...ux-foundation.org>,
Lai Jiangshan <jiangshanlai@...il.com>
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.
Powered by blists - more mailing lists