[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAB8ipk9UqS8h+nAUUaORr0K-VQaMWZEcoHLbKQDmeNZPMORiPA@mail.gmail.com>
Date: Wed, 19 Feb 2025 15:14:56 +0800
From: Xuewen Yan <xuewen.yan94@...il.com>
To: Vincent Guittot <vincent.guittot@...aro.org>
Cc: Xuewen Yan <xuewen.yan@...soc.com>, mingo@...hat.com, peterz@...radead.org,
juri.lelli@...hat.com, dietmar.eggemann@....com, rostedt@...dmis.org,
bsegall@...gle.com, mgorman@...e.de, vschneid@...hat.com, qyousef@...alina.io,
ke.wang@...soc.com, di.shen@...soc.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] sched/uclamp: Add uclamp_is_used() check before
enable it
On Wed, Feb 19, 2025 at 1:24 AM Vincent Guittot
<vincent.guittot@...aro.org> wrote:
>
> On Thu, 13 Feb 2025 at 10:18, Xuewen Yan <xuewen.yan@...soc.com> wrote:
> >
> > Because the static_branch_enable() would get the cpus_read_lock(),
> > and sometimes users may frequently set the uclamp value of tasks,
> > and the uclamp_validate() would call the static_branch_enable()
> > frequently, so add the uclamp_is_used() check to prevent calling
> > the cpus_read_lock() frequently.
>
> You should extended this to all calls to
> static_branch_enable(&sched_uclamp_used) which are cgroups and system
> wide uclamp
> Android likes to play with task's uclamp but the same could happen with others
>
> >
> > Signed-off-by: Xuewen Yan <xuewen.yan@...soc.com>
> > ---
> > kernel/sched/syscalls.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/kernel/sched/syscalls.c b/kernel/sched/syscalls.c
> > index 456d339be98f..d718fddadb03 100644
> > --- a/kernel/sched/syscalls.c
> > +++ b/kernel/sched/syscalls.c
> > @@ -368,7 +368,8 @@ static int uclamp_validate(struct task_struct *p,
> > * blocking operation which obviously cannot be done while holding
> > * scheduler locks.
> > */
> > - static_branch_enable(&sched_uclamp_used);
> > + if (!uclamp_is_used())
> > + static_branch_enable(&sched_uclamp_used);
>
> may be use a helper function to encapsulate this and use it everywhere
> we enable sched_uclamp_used
>
Okay, thank you very much for your suggestion, I would modify it in patch-v2.
BR
> >
> > return 0;
> > }
> > --
> > 2.25.1
> >
Powered by blists - more mailing lists