Re: [PATCH v11 1/4] cpu/SMT: Provide a default topology_is_primary_thread()

Dietmar Eggemann
2025-02-28T11:55:18Z

On 18/02/2025 15:10, Yicong Yang wrote:
> From: Yicong Yang <yangyicong@hisilicon.com>

[...]

> diff --git a/include/linux/topology.h b/include/linux/topology.h
> index 52f5850730b3..b3aba443c4eb 100644
> --- a/include/linux/topology.h
> +++ b/include/linux/topology.h
> @@ -240,6 +240,28 @@ static inline const struct cpumask *cpu_smt_mask(int cpu)
> }
> #endif
>
> +#ifndef topology_is_primary_thread
> +
> +#define topology_is_primary_thread topology_is_primary_thread
> +
> +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.
> + *
> + * The sibling cpumask of an offline CPU contains always the CPU
> + * itself for architectures using CONFIG_GENERIC_ARCH_TOPOLOGY.
> + * Other architectures should use this depend on their own
> + * situation.

This sentence is hard to get. Do you want to say that other
architectures (CONFIG_GENERIC_ARCH_TOPOLOGY or
!CONFIG_GENERIC_ARCH_TOPOLOGY) have to check whether they can use this
default implementation or have to override it? …