[PATCH v7 1/4] cpu/SMT: Provide a default topology_is_primary_thread()
Pierre Gondois
pierre.gondois at arm.com
Fri Nov 8 04:20:29 AEDT 2024
On 10/31/24 13:17, Yicong Yang wrote:
> On 2024/10/30 22:55, Thomas Gleixner wrote:
>> On Wed, Oct 30 2024 at 20:54, Yicong Yang wrote:
>>>
>>> +#ifndef topology_is_primary_thread
>>> +#define topology_is_primary_thread topology_is_primary_thread
>>
>> Please do not glue defines and functions together w/o a newline in between.
>>
>
> sure, will add a newline here.
>
>>> +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.
>
> 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
>
> Also tested fine in practice.
>
> Thanks.
>
>
FWIW, I also tested the case where:
- setting maxcpus=1 in the kernel cmdline to have CPUs that never booted
- setting smt to off:
'echo off > /sys/devices/system/cpu/smt/control'
and effectively the primary CPUs can boot and secondary CPUs can't,
so it works as expected.
More information about the Linuxppc-dev
mailing list