From: Dave Hansen <dave.hansen@intel.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
Linux PM <linux-pm@vger.kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
LKML <linux-kernel@vger.kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Christian Loehle <christian.loehle@arm.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
the arch/x86 maintainers <x86@kernel.org>
Subject: Re: [PATCH v1] cpu: Add missing check to cpuhp_smt_enable()
Date: Tue, 2 Sep 2025 09:56:20 -0700 [thread overview]
Message-ID: <4f340f1e-1cbf-4b50-ae23-a0e50170146c@intel.com> (raw)
In-Reply-To: <CAJZ5v0ik7fRKwH3CnXysvBJkkdJbWP-6iL=zBF0o92rR+nHTKg@mail.gmail.com>
On 9/2/25 08:05, Rafael J. Wysocki wrote:
> On Fri, Aug 29, 2025 at 10:01 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
>> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>> Christian has reported that commit a430c11f4015 ("intel_idle: Rescan
>> "dead" SMT siblings during initialization") broke the use case in
Does "dead" here mean present but offline?
>> which both nosmt and maxcpus were added to the kernel command line
>> because it caused CPUs that were not SMT siblings to be brought
>> online during the intel_idle driver initialization in violation of the
>> maxcpus limit.
How does intel_idle fit in here? I don't immediately see it calling
cpuhp_smt_enable().
>> The underlying reason for this is a missing topology_is_primary_thread()
>> check in cpuhp_smt_enable() which causes that function to put online
>> more CPUs than just the SMT siblings that it is supposed to handle.
>>
>> Add the missing check to address the issue.
We should probably add a bit more checking in cpuhp_smt_enable() to make
sure that it's being called under expected conditions like a:
WARN_ON_ONCE(cpu_smt_control != CPU_SMT_DISABLED);
and probably also some comments about how it is expected to work.
cpuhp_smt_enable() doesn't _really_ enable SMT. It specifically takes it
from DISABLED=>ENABLED. Thinking about it in that context, enabling
_just_ the secondary (disabled) threads makes a lot of sense.
But that can come later, after the bug fix.
>> --- a/kernel/cpu.c
>> +++ b/kernel/cpu.c
>> @@ -2710,6 +2710,12 @@
No 'diff -p', eh?
>> cpu_maps_update_begin();
>> cpu_smt_control = CPU_SMT_ENABLED;
>> for_each_present_cpu(cpu) {
>> + /*
>> + * Avoid accidentally onlining primary thread CPUs that have
>> + * been taken offline.
>> + */
>> + if (topology_is_primary_thread(cpu))
>> + continue;
>> /* Skip online CPUs and CPUs on offline nodes */
>> if (cpu_online(cpu) || !node_online(cpu_to_node(cpu)))
>> continue;
Is there a more generic problem with this not respecting 'maxcpus'? If
maxcpus had forced a primary thread offline, this would still online the
secondary thread, even with the fix. Taking _that_ online might still
bring you over the maxcpus limit.
next prev parent reply other threads:[~2025-09-02 16:56 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-29 20:01 [PATCH v1] cpu: Add missing check to cpuhp_smt_enable() Rafael J. Wysocki
2025-09-02 15:05 ` Rafael J. Wysocki
2025-09-02 16:56 ` Dave Hansen [this message]
2025-09-02 17:18 ` Rafael J. Wysocki
2025-09-03 18:00 ` Dave Hansen
2025-09-03 18:35 ` Rafael J. Wysocki
2025-09-05 7:39 ` Thomas Gleixner
2025-09-05 13:13 ` Rafael J. Wysocki
2025-09-05 13:27 ` Rafael J. Wysocki
2025-09-05 20:47 ` Thomas Gleixner
2025-09-05 20:56 ` Rafael J. Wysocki
2025-09-07 13:14 ` Thomas Gleixner
2025-09-11 10:31 ` Rafael J. Wysocki
2025-09-21 8:56 ` [PATCH] x86/topology: Implement topology_is_core_online() to address SMT regression Thomas Gleixner
2025-09-21 11:00 ` Christian Loehle
2025-09-22 15:42 ` Rafael J. Wysocki
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=4f340f1e-1cbf-4b50-ae23-a0e50170146c@intel.com \
--to=dave.hansen@intel.com \
--cc=christian.loehle@arm.com \
--cc=dave.hansen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=rafael@kernel.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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