From: Peter Zijlstra <peterz@infradead.org>
To: Li kunyu <likunyu@open-hieco.net>
Cc: mingo@redhat.com, juri.lelli@redhat.com,
vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
vschneid@redhat.com, kprateek.nayak@amd.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sched/fair: Use atomic_long_sub() in clear_tg_load_avg()
Date: Mon, 30 Nov 2026 13:03:50 +0100 [thread overview]
Message-ID: <20261130120350.GM2668804@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20261130083500.5131-1-likunyu@open-hieco.net>
On Mon, Nov 30, 2026 at 04:34:59PM +0800, Li kunyu wrote:
> clear_tg_load_avg() currently builds negative deltas with temporary
> variables dl and dr, then calls atomic_long_add() to subtract the
> cfs_rq's load and runnable contributions from the task group's shared
> load_avg and runnable_avg.
>
> Use atomic_long_sub() directly instead. This makes the subtraction
> explicit and drops the temporary variables.
>
> Signed-off-by: Li kunyu <likunyu@open-hieco.net>
> ---
> kernel/sched/fair.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index da0d9e19c457..5338ae9b5565 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -5370,7 +5370,6 @@ static inline void update_tg_load_avg(struct cfs_rq *cfs_rq)
>
> static inline void clear_tg_load_avg(struct cfs_rq *cfs_rq)
> {
> - long dl, dr;
> u64 now;
>
> /*
> @@ -5380,10 +5379,8 @@ static inline void clear_tg_load_avg(struct cfs_rq *cfs_rq)
> return;
>
> now = rq_clock(rq_of(cfs_rq));
> - dl = 0 - cfs_rq->tg_load_avg_contrib;
> - dr = 0 - cfs_rq->tg_runnable_avg_contrib;
> - atomic_long_add(dl, &cfs_rq->tg->load_avg);
> - atomic_long_add(dr, &cfs_rq->tg->runnable_avg);
> + atomic_long_sub(cfs_rq->tg_load_avg_contrib, &cfs_rq->tg->load_avg);
> + atomic_long_sub(cfs_rq->tg_runnable_avg_contrib, &cfs_rq->tg->runnable_avg);
> cfs_rq->tg_load_avg_contrib = 0;
> cfs_rq->tg_runnable_avg_contrib = 0;
> cfs_rq->last_update_tg_load_avg = now;
Yeah, no. This way the code has the same form as the function above.
prev parent reply other threads:[~2026-11-30 12:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 8:34 Li kunyu
2026-11-30 12:03 ` Peter Zijlstra [this message]
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=20261130120350.GM2668804@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=likunyu@open-hieco.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.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®