mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-15 08:44:14 +08:00
cpu/SMT: Create topology_smt_thread_allowed()
Some architectures allows partial SMT states, i.e. when not all SMT threads are brought online. To support that, add an architecture helper which checks whether a given CPU is allowed to be brought online depending on how many SMT threads are currently enabled. Since this is only applicable to architecture supporting partial SMT, only these architectures should select the new configuration variable CONFIG_SMT_NUM_THREADS_DYNAMIC. For the other architectures, not supporting the partial SMT states, there is no need to define topology_cpu_smt_allowed(), the generic code assumed that all the threads are allowed or only the primary ones. Call the helper from cpu_smt_enable(), and cpu_smt_allowed() when SMT is enabled, to check if the particular thread should be onlined. Notably, also call it from cpu_smt_disable() if CPU_SMT_ENABLED, to allow offlining some threads to move from a higher to lower number of threads online. [ ldufour: Slightly reword the commit's description ] [ ldufour: Introduce CONFIG_SMT_NUM_THREADS_DYNAMIC ] Suggested-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Signed-off-by: Laurent Dufour <ldufour@linux.ibm.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Zhang Rui <rui.zhang@intel.com> Link: https://lore.kernel.org/r/20230705145143.40545-7-ldufour@linux.ibm.com
This commit is contained in:
parent
91b4a7dbfe
commit
38253464bc
@ -34,6 +34,9 @@ config ARCH_HAS_SUBPAGE_FAULTS
|
|||||||
config HOTPLUG_SMT
|
config HOTPLUG_SMT
|
||||||
bool
|
bool
|
||||||
|
|
||||||
|
config SMT_NUM_THREADS_DYNAMIC
|
||||||
|
bool
|
||||||
|
|
||||||
# Selected by HOTPLUG_CORE_SYNC_DEAD or HOTPLUG_CORE_SYNC_FULL
|
# Selected by HOTPLUG_CORE_SYNC_DEAD or HOTPLUG_CORE_SYNC_FULL
|
||||||
config HOTPLUG_CORE_SYNC
|
config HOTPLUG_CORE_SYNC
|
||||||
bool
|
bool
|
||||||
|
24
kernel/cpu.c
24
kernel/cpu.c
@ -645,9 +645,23 @@ static int __init smt_cmdline_disable(char *str)
|
|||||||
}
|
}
|
||||||
early_param("nosmt", smt_cmdline_disable);
|
early_param("nosmt", smt_cmdline_disable);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* For Archicture supporting partial SMT states check if the thread is allowed.
|
||||||
|
* Otherwise this has already been checked through cpu_smt_max_threads when
|
||||||
|
* setting the SMT level.
|
||||||
|
*/
|
||||||
|
static inline bool cpu_smt_thread_allowed(unsigned int cpu)
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_SMT_NUM_THREADS_DYNAMIC
|
||||||
|
return topology_smt_thread_allowed(cpu);
|
||||||
|
#else
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static inline bool cpu_smt_allowed(unsigned int cpu)
|
static inline bool cpu_smt_allowed(unsigned int cpu)
|
||||||
{
|
{
|
||||||
if (cpu_smt_control == CPU_SMT_ENABLED)
|
if (cpu_smt_control == CPU_SMT_ENABLED && cpu_smt_thread_allowed(cpu))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (topology_is_primary_thread(cpu))
|
if (topology_is_primary_thread(cpu))
|
||||||
@ -2642,6 +2656,12 @@ int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval)
|
|||||||
for_each_online_cpu(cpu) {
|
for_each_online_cpu(cpu) {
|
||||||
if (topology_is_primary_thread(cpu))
|
if (topology_is_primary_thread(cpu))
|
||||||
continue;
|
continue;
|
||||||
|
/*
|
||||||
|
* Disable can be called with CPU_SMT_ENABLED when changing
|
||||||
|
* from a higher to lower number of SMT threads per core.
|
||||||
|
*/
|
||||||
|
if (ctrlval == CPU_SMT_ENABLED && cpu_smt_thread_allowed(cpu))
|
||||||
|
continue;
|
||||||
ret = cpu_down_maps_locked(cpu, CPUHP_OFFLINE);
|
ret = cpu_down_maps_locked(cpu, CPUHP_OFFLINE);
|
||||||
if (ret)
|
if (ret)
|
||||||
break;
|
break;
|
||||||
@ -2676,6 +2696,8 @@ int cpuhp_smt_enable(void)
|
|||||||
/* Skip online CPUs and CPUs on offline nodes */
|
/* Skip online CPUs and CPUs on offline nodes */
|
||||||
if (cpu_online(cpu) || !node_online(cpu_to_node(cpu)))
|
if (cpu_online(cpu) || !node_online(cpu_to_node(cpu)))
|
||||||
continue;
|
continue;
|
||||||
|
if (!cpu_smt_thread_allowed(cpu))
|
||||||
|
continue;
|
||||||
ret = _cpu_up(cpu, 0, CPUHP_ONLINE);
|
ret = _cpu_up(cpu, 0, CPUHP_ONLINE);
|
||||||
if (ret)
|
if (ret)
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user