All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched/cpuacct: show only present CPUs to userspace
@ 2024-10-17 10:21 Alexander Mikhalitsyn
  2024-10-25 15:35 ` Aleksandr Mikhalitsyn
  2024-10-28 13:23 ` Peter Zijlstra
  0 siblings, 2 replies; 6+ messages in thread
From: Alexander Mikhalitsyn @ 2024-10-17 10:21 UTC (permalink / raw)
  To: mingo
  Cc: James Morse, Jonathan Cameron, Gavin Shan, Russell King (Oracle),
	Thomas Gleixner, Simon Deziel, Alexander Mikhalitsyn,
	Peter Zijlstra, Juri Lelli, Vincent Guittot, Dietmar Eggemann,
	Steven Rostedt, Ben Segall, Mel Gorman, Valentin Schneider,
	linux-kernel

After commit b0c69e1214bc ("drivers: base: Use present CPUs in GENERIC_CPU_DEVICES")
changed which CPUs are shown in /sys/devices/system/cpu/ (only "present" ones)
it also makes sense to change cpuacct cgroupv1 code not to report CPUs
which are not present in the system as it confuses userspace.
Let's make it consistent.

A configuration when #(present CPUs) < #(possible CPUs) is easy to get with:
qemu-system-x86_64
	-smp 3,maxcpus=12 \
	...

Cc: James Morse <james.morse@arm.com>
Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Gavin Shan <gshan@redhat.com>
Cc: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
Cc: Thomas Gleixner <tglx@linutronix.de>
Reported-by: Simon Deziel <simon.deziel@canonical.com>
Closes: https://github.com/canonical/lxd/issues/13324
Co-developed-by: Simon Deziel <simon.deziel@canonical.com>
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
---
 kernel/sched/cpuacct.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/cpuacct.c b/kernel/sched/cpuacct.c
index 0de9dda09949..0f07fbfdb20e 100644
--- a/kernel/sched/cpuacct.c
+++ b/kernel/sched/cpuacct.c
@@ -213,7 +213,7 @@ static int __cpuacct_percpu_seq_show(struct seq_file *m,
 	u64 percpu;
 	int i;
 
-	for_each_possible_cpu(i) {
+	for_each_present_cpu(i) {
 		percpu = cpuacct_cpuusage_read(ca, i, index);
 		seq_printf(m, "%llu ", (unsigned long long) percpu);
 	}
@@ -247,7 +247,7 @@ static int cpuacct_all_seq_show(struct seq_file *m, void *V)
 		seq_printf(m, " %s", cpuacct_stat_desc[index]);
 	seq_puts(m, "\n");
 
-	for_each_possible_cpu(cpu) {
+	for_each_present_cpu(cpu) {
 		seq_printf(m, "%d", cpu);
 		for (index = 0; index < CPUACCT_STAT_NSTATS; index++)
 			seq_printf(m, " %llu",
-- 
2.34.1


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

end of thread, other threads:[~2024-11-08 13:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-17 10:21 [PATCH] sched/cpuacct: show only present CPUs to userspace Alexander Mikhalitsyn
2024-10-25 15:35 ` Aleksandr Mikhalitsyn
2024-10-28 11:07   ` Jonathan Cameron
2024-11-08 13:00     ` Aleksandr Mikhalitsyn
2024-10-28 13:23 ` Peter Zijlstra
2024-11-08 13:17   ` Aleksandr Mikhalitsyn

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.