From: Zhan Xusheng <zhanxusheng1024@gmail.com>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: Juri Lelli <juri.lelli@redhat.com>,
linux-kernel@vger.kernel.org,
Zhan Xusheng <zhanxusheng@xiaomi.com>
Subject: [PATCH v3] sched/psi: Skip CPUs with zero non-idle jiffies in per-CPU aggregation
Date: Fri, 13 Mar 2026 11:48:47 +0800 [thread overview]
Message-ID: <20260313034847.1422-1-zhanxusheng@xiaomi.com> (raw)
In-Reply-To: <20260204022328.23938-1-zhanxusheng@xiaomi.com>
To improve performance during per-CPU aggregation, skip CPUs that have
zero non-idle jiffies early in the process. These CPUs do not contribute
to the weighted result and can be excluded from the per-CPU calculations.
The change directly checks the `cpu_changed_states` for `PSI_NONIDLE`
instead of performing unnecessary arithmetic.
No functional change intended.
Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>
Reviewed-by: Johannes Weiner <hannes@cmpxchg.org>
---
kernel/sched/psi.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c
index d9c9d9480a45..65f09282143e 100644
--- a/kernel/sched/psi.c
+++ b/kernel/sched/psi.c
@@ -384,6 +384,13 @@ static void collect_percpu_times(struct psi_group *group,
get_recent_times(group, cpu, aggregator, times,
&cpu_changed_states);
+ /*
+ * Skip CPUs with no non-idle time. These CPUs do not contribute
+ * to the weighted per-CPU aggregation, so we can avoid unnecessary
+ * calculations for them by checking cpu_changed_states.
+ */
+ if (!(cpu_changed_states & (1 << PSI_NONIDLE)))
+ continue;
changed_states |= cpu_changed_states;
nonidle = nsecs_to_jiffies(times[PSI_NONIDLE]);
--
2.43.0
next prev parent reply other threads:[~2026-03-13 3:48 UTC|newest]
Thread overview: 8+ 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
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 ` Zhan Xusheng [this message]
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
2026-08-04 9:25 ` [PATCH v6] " 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=20260313034847.1422-1-zhanxusheng@xiaomi.com \
--to=zhanxusheng1024@gmail.com \
--cc=hannes@cmpxchg.org \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--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 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®