[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20260204022328.23938-1-zhanxusheng@xiaomi.com>
Date: Wed, 4 Feb 2026 10:23:28 +0800
From: Zhan Xusheng <zhanxusheng1024@...il.com>
To: Johannes Weiner <hannes@...xchg.org>
Cc: linux-kernel@...r.kernel.org,
linux-sched@...r.kernel.org,
Zhan Xusheng <zhanxusheng@...omi.com>
Subject: [PATCH v2] sched/psi: Skip CPUs with zero non-idle jiffies in per-CPU aggregation
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@...omi.com>
Reviewed-by: Johannes Weiner <hannes@...xchg.org>
---
kernel/sched/psi.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c
index 59fdb7ebbf22..f1bf5449d3f9 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
Powered by blists - more mailing lists