From: Yicong Yang <yangyicong@huawei.com>
To: Thomas Gleixner <tglx@linutronix.de>, <catalin.marinas@arm.com>,
<will@kernel.org>, <sudeep.holla@arm.com>, <peterz@infradead.org>,
<mpe@ellerman.id.au>, <linux-arm-kernel@lists.infradead.org>,
<mingo@redhat.com>, <bp@alien8.de>, <dave.hansen@linux.intel.com>,
<pierre.gondois@arm.com>, <dietmar.eggemann@arm.com>
Cc: <yangyicong@hisilicon.com>, <linuxppc-dev@lists.ozlabs.org>,
<x86@kernel.org>, <linux-kernel@vger.kernel.org>,
<morten.rasmussen@arm.com>, <msuchanek@suse.de>,
<gregkh@linuxfoundation.org>, <rafael@kernel.org>,
<jonathan.cameron@huawei.com>, <prime.zeng@hisilicon.com>,
<linuxarm@huawei.com>, <xuwei5@huawei.com>,
<guohanjun@huawei.com>
Subject: Re: [PATCH v7 1/4] cpu/SMT: Provide a default topology_is_primary_thread()
Date: Fri, 1 Nov 2024 11:18:33 +0800 [thread overview]
Message-ID: <5617934d-45ac-509a-510e-d96d52a2ebf9@huawei.com> (raw)
In-Reply-To: <87frocwg64.ffs@tglx>
On 2024/10/31 21:33, Thomas Gleixner wrote:
> On Thu, Oct 31 2024 at 20:17, Yicong Yang wrote:
>> On 2024/10/30 22:55, Thomas Gleixner wrote:
>>>> +static inline bool topology_is_primary_thread(unsigned int cpu)
>>>> +{
>>>> + /*
>>>> + * On SMT hotplug the primary thread of the SMT won't be disabled.
>>>> + * Architectures do have a special primary thread (e.g. x86) need
>>>> + * to override this function. Otherwise just make the first thread
>>>> + * in the SMT as the primary thread.
>>>> + */
>>>> + return cpu == cpumask_first(topology_sibling_cpumask(cpu));
>>>
>>> How is that supposed to work? Assume both siblings are offline, then the
>>> sibling mask is empty and you can't boot the CPU anymore.
>>>
>>
>> For architectures' using arch_topology, topology_sibling_cpumask() will at least
>> contain the tested CPU itself. This is initialized in
>> drivers/base/arch_topology.c:reset_cpu_topology(). So it won't be
>> empty here.
>
> Fair enough. Can you please expand the comment and say:
>
> The sibling cpumask of a offline CPU contains always the CPU
> itself.
>
Sure, will make it clear.
>> Besides we don't need to check topology_is_primary_thread() at boot time:
>> -> cpu_up(cpu)
>> cpu_bootable()
>> if (cpu_smt_control == CPU_SMT_ENABLED &&
>> cpu_smt_thread_allowed(cpu)) // will always return true if !CONFIG_SMT_NUM_THREADS_DYNAMIC
>> return true; // we'll always return here and @cpu is always bootable
>
> cpu_smt_control is not guaranteed to have CPU_SMT_ENABLED state, so this
> argument is bogus.
>
sorry for didn't explain all the cases here.
For cpu_sm_control == {CPU_SMT_ENABLED, CPU_SMT_NOT_SUPPORTED, CPU_SMT_NOT_IMPLEMENTED},
all the cpu's bootable and we won't check topology_is_primary_thread().
static inline bool cpu_bootable(unsigned int cpu)
{
if (cpu_smt_control == CPU_SMT_ENABLED && cpu_smt_thread_allowed(cpu))
return true;
/* All CPUs are bootable if controls are not configured */
if (cpu_smt_control == CPU_SMT_NOT_IMPLEMENTED)
return true;
/* All CPUs are bootable if CPU is not SMT capable */
if (cpu_smt_control == CPU_SMT_NOT_SUPPORTED)
return true;
if (topology_is_primary_thread(cpu)) // Will be true for all the CPUs when thread sibling's not built
// Only true for primary thread if thread sibling's updated
// thread sibling will be updated once the CPU's bootup, for arm64
// in secondary_start_kernel()
return true;
return !cpumask_test_cpu(cpu, &cpus_booted_once_mask); // Also be updated once the CPU's bootup, in
// secondary_start_kernel() for arm64
// Will return false in the second check of
// cpu_bootable() in the call chain below
}
For cpu_smt_control == {CPUS_SMT_DISABLED, CPU_SMT_FORCE_DISABLED} if user specified the
boot option "nosmt" or "nosmt=force", it'll be a bit more complex. For a non-primary
thread CPU, cpu_bootable() will return true and it'll be boot. Then after thread sibling's
built cpu_bootable() will be checked secondly it the cpuhp callbacks, since it'll return
false then and we'll roll back and offline it.
// for a non-primary thread CPU, system boot with "nosmt" or "nosmt=force"
-> cpu_up()
cpu_bootable() -> true, since the thread sibling mask only coutains CPU itself
[...]
cpuhp_bringup_ap()
bringup_wait_for_ap_online()
if (!cpu_bootable(cpu)) // target CPU has been bringup, thread sibling mask's updated
// then this non-primay thread won't be bootable in this case
return -ECANCELED // roll back and offline this CPU
Thanks.
next prev parent reply other threads:[~2024-11-01 3:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-30 12:54 [PATCH v7 0/4] Support SMT control on arm64 Yicong Yang
2024-10-30 12:54 ` [PATCH v7 1/4] cpu/SMT: Provide a default topology_is_primary_thread() Yicong Yang
2024-10-30 14:55 ` Thomas Gleixner
2024-10-31 12:17 ` Yicong Yang
2024-10-31 13:33 ` Thomas Gleixner
2024-11-01 3:18 ` Yicong Yang [this message]
2024-11-01 9:31 ` Thomas Gleixner
2024-11-07 17:20 ` Pierre Gondois
2024-10-30 12:54 ` [PATCH v7 2/4] arch_topology: Support SMT control for OF based system Yicong Yang
2024-10-30 12:54 ` [PATCH v7 3/4] arm64: topology: Support SMT control on ACPI " Yicong Yang
2024-11-07 17:20 ` Pierre Gondois
2024-11-08 8:06 ` Yicong Yang
2024-10-30 12:54 ` [PATCH v7 4/4] arm64: Kconfig: Enable HOTPLUG_SMT Yicong Yang
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=5617934d-45ac-509a-510e-d96d52a2ebf9@huawei.com \
--to=yangyicong@huawei.com \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=dave.hansen@linux.intel.com \
--cc=dietmar.eggemann@arm.com \
--cc=gregkh@linuxfoundation.org \
--cc=guohanjun@huawei.com \
--cc=jonathan.cameron@huawei.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mingo@redhat.com \
--cc=morten.rasmussen@arm.com \
--cc=mpe@ellerman.id.au \
--cc=msuchanek@suse.de \
--cc=peterz@infradead.org \
--cc=pierre.gondois@arm.com \
--cc=prime.zeng@hisilicon.com \
--cc=rafael@kernel.org \
--cc=sudeep.holla@arm.com \
--cc=tglx@linutronix.de \
--cc=will@kernel.org \
--cc=x86@kernel.org \
--cc=xuwei5@huawei.com \
--cc=yangyicong@hisilicon.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®