public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched/psi: Skip CPUs with zero non-idle jiffies in per-cpu aggregation
@ 2026-02-03 10:00 Zhan Xusheng
  2026-02-03 16:46 ` Johannes Weiner
  0 siblings, 1 reply; 4+ messages in thread
From: Zhan Xusheng @ 2026-02-03 10:00 UTC (permalink / raw)
  To: Johannes Weiner; +Cc: linux-kernel, linux-sched, Zhan Xusheng

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>
---
 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;
 		nonidle_total += nonidle;
 
 		for (s = 0; s < PSI_NONIDLE; s++)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-03-13  3:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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     ` [PATCH v3] " Zhan Xusheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox