From: Vishal Chourasia <vishalc@linux.ibm.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: peterz@infradead.org, aboorvad@linux.ibm.com,
boqun.feng@gmail.com, frederic@kernel.org, joelagnelf@nvidia.com,
josh@joshtriplett.org, linux-kernel@vger.kernel.org,
neeraj.upadhyay@kernel.org, paulmck@kernel.org,
rcu@vger.kernel.org, rostedt@goodmis.org, srikar@linux.ibm.com,
sshegde@linux.ibm.com, urezki@gmail.com, samir@linux.ibm.com
Subject: Re: [PATCH v3 1/2] cpuhp: Optimize SMT switch operation by batching lock acquisition
Date: Thu, 26 Mar 2026 15:36:12 +0530 [thread overview]
Message-ID: <acUFFEab8b_OLqJg@linux.ibm.com> (raw)
In-Reply-To: <87ikajenfm.ffs@tglx>
Hi Thomas, Thank you for the review.
Numbers from 400 CPUs that I had while back,
baseline: Linux 6.19.0-rc4-00310-g755bc1335e3b
On PPC64 system with 400 CPUs:
SMT8 to SMT1:
baseline: real 1m14.792s
baseline+patch: real 0m03.205s # ~23x improvement
SMT1 to SMT8:
baseline: real 2m27.695s
baseline+patch: real 0m02.510s # ~58x improvement
Note: We observe huge improvements for max config system which
originally took approx to 1 hour to switch SMT states, with GPs
expedited is taking 5 to 6 minutes.
Analysis: why expediting GPs improves time to complete
By expediting the grace period, we force an immediate IPI-driven
quiescent state detection across all CPUs rather than lazily waiting,
which dramatically reduces the time the calling thread remains blocked
in synchronize_rcu()
Why holding the cpus_write_lock() for the duration of SMT switch will
not work? [1] This causes hung-task timeout splats [2] because there are
threads blocked on cpus_read_lock(). Expediting grace periods shrinks
the window but doesn't eliminate it. I plan to drop this patch and the
next version will only carry the expedited RCU grace period change.
I will incorporate all your other suggestions in the next version.
[1] https://lore.kernel.org/all/20260113090153.GS830755@noisy.programming.kicks-ass.net/
[2] https://lore.kernel.org/all/aapprY-prH0l_WeK@linux.ibm.com/
On Wed, Mar 25, 2026 at 08:09:17PM +0100, Thomas Gleixner wrote:
> On Wed, Feb 18 2026 at 14:09, Vishal Chourasia wrote:
> > From: Joel Fernandes <joelagnelf@nvidia.com>
> >
> > Bulk CPU hotplug operations, such as an SMT switch operation, requires
> > hotplugging multiple CPUs. The current implementation takes
> > cpus_write_lock() for each individual CPU, causing multiple slow grace
> > period requests.
> >
> > Introduce cpu_up_locked() and cpu_down_locked() that assume the caller
> > already holds cpus_write_lock(). The cpuhp_smt_enable() and
> > cpuhp_smt_disable() functions are updated to hold the lock once around
> > the entire loop, rather than for each individual CPU.
> >
> > Link: https://lore.kernel.org/all/20260113090153.GS830755@noisy.programming.kicks-ass.net/
> > Suggested-by: Peter Zijlstra <peterz@infradead.org>
> > Signed-off-by: Vishal Chourasia <vishalc@linux.ibm.com>
>
> You dropped Joel's Signed-off-by ....
Sorry for messing up the changelog w.r.t to signed-off-by tag.
Will take care in future.
>
> > -/* Requires cpu_add_remove_lock to be held */
> > -static int __ref _cpu_down(unsigned int cpu, int tasks_frozen,
> > +/* Requires cpu_add_remove_lock and cpus_write_lock to be held */
> > +static int __ref cpu_down_locked(unsigned int cpu, int tasks_frozen,
> > enum cpuhp_state target)
>
> No line break required. You have 100 chars. If you still need one:
>
> https://www.kernel.org/doc/html/latest/process/maintainer-tip.html
Ack.
>
> > */
> > if (cpumask_any_and(cpu_online_mask,
> > housekeeping_cpumask(HK_TYPE_DOMAIN)) >= nr_cpu_ids) {
> > - ret = -EBUSY;
> > - goto out;
> > + return -EBUSY;
> > }
>
> Please remove the brackets. They are not longer required. All over the place.
Ack.
>
> > +static int __ref _cpu_down(unsigned int cpu, int tasks_frozen,
> > + enum cpuhp_state target)
> > +{
> > +
> > + int ret;
> > + cpus_write_lock();
>
> Coding style...
Ack.
>
> > + ret = cpu_down_locked(cpu, tasks_frozen, target);
> > cpus_write_unlock();
> > arch_smt_update();
> > return ret;
> > @@ -2659,6 +2674,16 @@ int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval)
> > int cpu, ret = 0;
> >
> > cpu_maps_update_begin();
> > + if (cpu_hotplug_offline_disabled) {
> > + ret = -EOPNOTSUPP;
> > + goto out;
> > + }
> > + if (cpu_hotplug_disabled) {
> > + ret = -EBUSY;
> > + goto out;
> > + }
> > + /* Hold cpus_write_lock() for entire batch operation. */
> > + cpus_write_lock();
>
> .... for the entire ...
>
> And please visiually separate things. Newlines exist for a reason.
Sure.
>
> Thanks,
>
> tglx
Thanks and Regards!
Vishalc
next prev parent reply other threads:[~2026-03-26 10:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-18 8:39 [PATCH v3 0/2] cpuhp: Improve SMT switch time via lock batching and RCU expedition Vishal Chourasia
2026-02-18 8:39 ` [PATCH v3 1/2] cpuhp: Optimize SMT switch operation by batching lock acquisition Vishal Chourasia
2026-03-25 19:09 ` Thomas Gleixner
2026-03-26 10:06 ` Vishal Chourasia [this message]
2026-02-18 8:39 ` [PATCH v3 2/2] cpuhp: Expedite RCU grace periods during SMT operations Vishal Chourasia
2026-02-27 1:13 ` Joel Fernandes
2026-03-02 11:47 ` Samir M
2026-03-06 5:44 ` Vishal Chourasia
2026-03-06 15:12 ` Paul E. McKenney
2026-03-20 18:49 ` Vishal Chourasia
2026-03-25 19:10 ` Thomas Gleixner
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=acUFFEab8b_OLqJg@linux.ibm.com \
--to=vishalc@linux.ibm.com \
--cc=aboorvad@linux.ibm.com \
--cc=boqun.feng@gmail.com \
--cc=frederic@kernel.org \
--cc=joelagnelf@nvidia.com \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=neeraj.upadhyay@kernel.org \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=rcu@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=samir@linux.ibm.com \
--cc=srikar@linux.ibm.com \
--cc=sshegde@linux.ibm.com \
--cc=tglx@linutronix.de \
--cc=urezki@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