From: Christian Loehle <christian.loehle@arm.com>
To: Xuewen Yan <xuewen.yan@unisoc.com>,
mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
vincent.guittot@linaro.org
Cc: dietmar.eggemann@arm.com, rostedt@goodmis.org,
bsegall@google.com, mgorman@suse.de, vschneid@redhat.com,
qyousef@layalina.io, ke.wang@unisoc.com, di.shen@unisoc.com,
xuewen.yan94@gmail.com, linux-kernel@vger.kernel.org,
Hongyan Xia <Hongyan.Xia2@arm.com>
Subject: Re: [PATCH 2/2] sched/uclamp: Add uclamp_is_used() check before enable it
Date: Thu, 13 Feb 2025 14:51:30 +0000 [thread overview]
Message-ID: <b9ab5474-0b43-4200-8217-5cd95b365cad@arm.com> (raw)
In-Reply-To: <20250213091554.2593-2-xuewen.yan@unisoc.com>
On 2/13/25 09:15, Xuewen Yan 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.
>
> Signed-off-by: Xuewen Yan <xuewen.yan@unisoc.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);
>
> return 0;
> }
Given that we never disable sched_uclamp_used once active this
is fine.
Reviewed-by: Christian Loehle <christian.loehle@arm.com>
next prev parent reply other threads:[~2025-02-13 14:51 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-13 9:15 [PATCH 1/2] sched/uclamp: Alaways using uclamp_is_used() Xuewen Yan
2025-02-13 9:15 ` [PATCH 2/2] sched/uclamp: Add uclamp_is_used() check before enable it Xuewen Yan
2025-02-13 14:51 ` Christian Loehle [this message]
2025-02-13 14:57 ` Hongyan Xia
2025-02-18 17:24 ` Vincent Guittot
2025-02-19 7:14 ` Xuewen Yan
2025-02-22 23:36 ` Qais Yousef
2025-02-24 1:55 ` Xuewen Yan
2025-02-24 23:38 ` Qais Yousef
2025-02-13 15:02 ` [PATCH 1/2] sched/uclamp: Alaways using uclamp_is_used() Hongyan Xia
2025-02-13 18:15 ` Christian Loehle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b9ab5474-0b43-4200-8217-5cd95b365cad@arm.com \
--to=christian.loehle@arm.com \
--cc=Hongyan.Xia2@arm.com \
--cc=bsegall@google.com \
--cc=di.shen@unisoc.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=ke.wang@unisoc.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=qyousef@layalina.io \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=xuewen.yan94@gmail.com \
--cc=xuewen.yan@unisoc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®