mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
Cc: mingo@redhat.com, James Morse <james.morse@arm.com>,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>,
	Gavin Shan <gshan@redhat.com>,
	"Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>,
	Thomas Gleixner <tglx@linutronix.de>,
	Simon Deziel <simon.deziel@canonical.com>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	Valentin Schneider <vschneid@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sched/cpuacct: show only present CPUs to userspace
Date: Mon, 28 Oct 2024 14:23:06 +0100	[thread overview]
Message-ID: <20241028132306.GP14555@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20241017102138.92504-1-aleksandr.mikhalitsyn@canonical.com>

On Thu, Oct 17, 2024 at 12:21:38PM +0200, Alexander Mikhalitsyn wrote:
> 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",


Doesn't this create problems for machines that support actual physical
hotplug?

Then all of a sudden, when a CPU with non-zero stats goes from present
to !present, the stats also go away, and any userspace looking at the
sum of stats over CPUs sees an unexplained dis-continuity.

  parent reply	other threads:[~2024-10-28 13:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-17 10:21 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 [this message]
2024-11-08 13:17   ` Aleksandr Mikhalitsyn

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=20241028132306.GP14555@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=aleksandr.mikhalitsyn@canonical.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=gshan@redhat.com \
    --cc=james.morse@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=rostedt@goodmis.org \
    --cc=simon.deziel@canonical.com \
    --cc=tglx@linutronix.de \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.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®