From: Thomas Gleixner <tglx@linutronix.de>
To: Ye Bin <yebin@huaweicloud.com>,
dennis@kernel.org, tj@kernel.org, cl@linux.com,
linux-mm@kvack.org, yury.norov@gmail.com,
andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk
Cc: linux-kernel@vger.kernel.org, dchinner@redhat.com,
yebin10@huawei.com, yebin@huaweicloud.com,
Peter Zijlstra <peterz@infradead.org>,
Valentin Schneider <vschneid@redhat.com>,
Linus Torvalds <torvalds@linuxfoundation.org>
Subject: Re: [PATCH v2 2/2] lib/percpu_counter: fix dying cpu compare race
Date: Tue, 11 Apr 2023 08:56:48 +0200 [thread overview]
Message-ID: <874jpm29fz.ffs@tglx> (raw)
In-Reply-To: <877cuj1mt1.ffs@tglx>
On Mon, Apr 10 2023 at 22:53, Thomas Gleixner wrote:
> On Thu, Apr 06 2023 at 09:56, Ye Bin wrote:
> cpu_dying_mask is a random number generator w/o cpu_hotplug_lock being
> held. And even with that lock held any cpumask operation on it is silly.
> The mask is a core detail:
>
> commit e40f74c535b8 "cpumask: Introduce DYING mask"
>
> Introduce a cpumask that indicates (for each CPU) what direction the
> CPU hotplug is currently going. Notably, it tracks rollbacks. Eg. when
> an up fails and we do a roll-back down, it will accurately reflect the
> direction.
>
> It does not tell anything to a user which is not aware of the actual
> hotplug state machine state.
Even if the mask is most of the time stable, it's a total disaster
performance wise. The bits in cpu_dying_mask are sticky until the next
online operation.
So for a system which has SMT enabled in BIOS, but SMT is disabled on
the kernel command line or later via the sysfs knob, this means that the
loop in __percpu_counter_sum() will iterate over all shutdown SMT
siblings forever. IOW, it will touch nr_of_shutdown_cpus() cachelines
for absolutely zero reason.
The same applies for the proposed counter.
Thanks,
tglx
prev parent reply other threads:[~2023-04-11 6:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-06 1:56 [PATCH v2 0/2] " Ye Bin
2023-04-06 1:56 ` [PATCH v2 1/2] cpu/hotplug: introduce 'num_dying_cpus' to get dying CPUs count Ye Bin
2023-04-10 17:42 ` Yury Norov
2023-04-10 20:12 ` Thomas Gleixner
2023-04-06 1:56 ` [PATCH v2 2/2] lib/percpu_counter: fix dying cpu compare race Ye Bin
2023-04-08 7:13 ` Dennis Zhou
2023-04-10 20:53 ` Thomas Gleixner
2023-04-11 6:56 ` Thomas Gleixner [this message]
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=874jpm29fz.ffs@tglx \
--to=tglx@linutronix.de \
--cc=andriy.shevchenko@linux.intel.com \
--cc=cl@linux.com \
--cc=dchinner@redhat.com \
--cc=dennis@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux@rasmusvillemoes.dk \
--cc=peterz@infradead.org \
--cc=tj@kernel.org \
--cc=torvalds@linuxfoundation.org \
--cc=vschneid@redhat.com \
--cc=yebin10@huawei.com \
--cc=yebin@huaweicloud.com \
--cc=yury.norov@gmail.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