All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Weiner <hannes@cmpxchg.org>
To: Zhan Xusheng <zhanxusheng1024@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-sched@vger.kernel.org,
	Zhan Xusheng <zhanxusheng@xiaomi.com>
Subject: Re: [PATCH] sched/psi: Skip CPUs with zero non-idle jiffies in per-cpu aggregation
Date: Tue, 3 Feb 2026 11:46:26 -0500	[thread overview]
Message-ID: <aYImYitSfznXIcsC@cmpxchg.org> (raw)
In-Reply-To: <20260203100007.22044-1-zhanxusheng@xiaomi.com>

On Tue, Feb 03, 2026 at 06:00:07PM +0800, Zhan Xusheng wrote:
> PSI per-cpu aggregation weights each CPU's contribution by its
> non-idle time converted to jiffies. CPUs with zero non-idle jiffies
> do not contribute to the weighted result, but are still processed in
> the current implementation.
> 
> Skip CPUs with zero non-idle jiffies early to avoid unnecessary
> per-cpu arithmetic during aggregation.
> 
> No functional change intended.
> 
> Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>

Makes sense.

> ---
>  kernel/sched/psi.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c
> index 59fdb7ebbf22..ce2321793a67 100644
> --- a/kernel/sched/psi.c
> +++ b/kernel/sched/psi.c
> @@ -387,6 +387,13 @@ static void collect_percpu_times(struct psi_group *group,
>  		changed_states |= cpu_changed_states;
>  
>  		nonidle = nsecs_to_jiffies(times[PSI_NONIDLE]);
> +		/*
> +		 * A CPU with zero non-idle jiffies does not contribute to the
> +		 * weighted per-CPU aggregation. There is no need to include it
> +		 * in deltas or total accumulation.
> +		 */
> +		if (!nonidle)
> +			continue;

You could save the nsecs_to_jiffies() dance as well by doing:

		if (!(cpu_changed_states & (1 << PSI_NONIDLE)))
			coninue;

  reply	other threads:[~2026-02-03 16:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-03 10:00 [PATCH] sched/psi: Skip CPUs with zero non-idle jiffies in per-cpu aggregation Zhan Xusheng
2026-02-03 16:46 ` Johannes Weiner [this message]
2026-02-04  2:23   ` [PATCH v2] sched/psi: Skip CPUs with zero non-idle jiffies in per-CPU aggregation Zhan Xusheng
2026-03-13  3:48     ` [PATCH v3] " Zhan Xusheng
2026-04-29 10:05   ` [PATCH v4] sched/psi: Skip CPUs with zero non-idle delta " Zhan Xusheng
2026-05-04  8:04     ` Peter Zijlstra
2026-05-07 13:56       ` [PATCH v5] " Zhan Xusheng

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=aYImYitSfznXIcsC@cmpxchg.org \
    --to=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sched@vger.kernel.org \
    --cc=zhanxusheng1024@gmail.com \
    --cc=zhanxusheng@xiaomi.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.