[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210524211624.GG15545@willie-the-truck>
Date: Mon, 24 May 2021 22:16:25 +0100
From: Will Deacon <will@...nel.org>
To: Qais Yousef <qais.yousef@....com>
Cc: linux-arm-kernel@...ts.infradead.org, linux-arch@...r.kernel.org,
linux-kernel@...r.kernel.org,
Catalin Marinas <catalin.marinas@....com>,
Marc Zyngier <maz@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Peter Zijlstra <peterz@...radead.org>,
Morten Rasmussen <morten.rasmussen@....com>,
Suren Baghdasaryan <surenb@...gle.com>,
Quentin Perret <qperret@...gle.com>, Tejun Heo <tj@...nel.org>,
Li Zefan <lizefan@...wei.com>,
Johannes Weiner <hannes@...xchg.org>,
Ingo Molnar <mingo@...hat.com>,
Juri Lelli <juri.lelli@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>,
"Rafael J. Wysocki" <rjw@...ysocki.net>, kernel-team@...roid.com
Subject: Re: [PATCH v6 11/21] sched: Split the guts of sched_setaffinity()
into a helper function
On Fri, May 21, 2021 at 05:41:01PM +0100, Qais Yousef wrote:
> On 05/18/21 10:47, Will Deacon wrote:
> > In preparation for replaying user affinity requests using a saved mask,
> > split sched_setaffinity() up so that the initial task lookup and
> > security checks are only performed when the request is coming directly
> > from userspace.
> >
> > Signed-off-by: Will Deacon <will@...nel.org>
> > ---
> > kernel/sched/core.c | 110 +++++++++++++++++++++++---------------------
> > 1 file changed, 58 insertions(+), 52 deletions(-)
> >
> > diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> > index 9512623d5a60..808bbe669a6d 100644
> > --- a/kernel/sched/core.c
> > +++ b/kernel/sched/core.c
> > @@ -6788,9 +6788,61 @@ SYSCALL_DEFINE4(sched_getattr, pid_t, pid, struct sched_attr __user *, uattr,
> > return retval;
> > }
> >
> > -long sched_setaffinity(pid_t pid, const struct cpumask *in_mask)
> > +static int
> > +__sched_setaffinity(struct task_struct *p, const struct cpumask *mask)
> > {
> > + int retval;
> > cpumask_var_t cpus_allowed, new_mask;
> > +
> > + if (!alloc_cpumask_var(&cpus_allowed, GFP_KERNEL))
> > + return -ENOMEM;
> > +
> > + if (!alloc_cpumask_var(&new_mask, GFP_KERNEL))
> > + return -ENOMEM;
>
> Shouldn't we free cpus_allowed first?
Oops, yes. Now fixed.
Thanks,
Will
Powered by blists - more mailing lists