Message ID | 20220217070419.351683-1-joel@jms.id.au (mailing list archive) |
---|---|
State | Changes Requested |
Headers | show |
Series | [RFC] powerpc: Implement hotplug smt control | expand |
Context | Check | Description |
---|---|---|
snowpatch_ozlabs/github-powerpc_kernel_qemu | fail | kernel (corenet64_smp_defconfig, korg-5.5.0, /linux/arch/powerpc/configs/ppc64e-qemu.config) failed at step build. |
snowpatch_ozlabs/github-powerpc_selftests | success | Successfully ran 8 jobs. |
snowpatch_ozlabs/github-powerpc_ppctests | success | Successfully ran 8 jobs. |
snowpatch_ozlabs/github-powerpc_clang | fail | kernel (corenet64_smp, ubuntu-21.04, ppc64) failed at step build. |
snowpatch_ozlabs/github-powerpc_sparse | success | Successfully ran 4 jobs. |
Le 17/02/2022 à 08:04, Joel Stanley a écrit : > x86 added a control for turning SMT on and off in commit 05736e4ac13c > ("cpu/hotplug: Provide knobs to control SMT"). > > Implement this for powerpc as an alternative to the currently method of > iterating through /sys/devices/system/cpu/cpuN/online for every CPU. > > # ppc64_cpu --info > Core 0: 0* 1* 2* 3* 4* 5* 6* 7* > Core 1: 8* 9* 10* 11* 12* 13* 14* 15* > # grep . /sys/devices/system/cpu/smt/* > /sys/devices/system/cpu/smt/active:1 > /sys/devices/system/cpu/smt/control:on > # echo off > /sys/devices/system/cpu/smt/control > # ppc64_cpu --info > Core 0: 0* 1 2 3 4 5 6 7 > Core 1: 8* 9 10 11 12 13 14 15 > # grep . /sys/devices/system/cpu/smt/* > /sys/devices/system/cpu/smt/active:0 > /sys/devices/system/cpu/smt/control:off > > Signed-off-by: Joel Stanley <joel@jms.id.au> Build fails with corenet64_smp_defconfig: CC kernel/cpu.o kernel/cpu.c: In function 'cpuhp_smt_disable': kernel/cpu.c:2220:23: error: implicit declaration of function 'cpu_down_maps_locked' [-Werror=implicit-function-declaration] 2220 | ret = cpu_down_maps_locked(cpu, CPUHP_OFFLINE); | ^~~~~~~~~~~~~~~~~~~~ cc1: some warnings being treated as errors make[1]: *** [scripts/Makefile.build:288: kernel/cpu.o] Error 1 Christophe
diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm/topology.h index 36fcafb1fd6d..58280ca4321c 100644 --- a/arch/powerpc/include/asm/topology.h +++ b/arch/powerpc/include/asm/topology.h @@ -147,5 +147,13 @@ static inline int cpu_to_coregroup_id(int cpu) #endif #endif +#ifdef CONFIG_HOTPLUG_CPU +bool topology_is_primary_thread(unsigned int cpu); +bool topology_smt_supported(void); +#else +static inline bool topology_is_primary_thread(unsigned int cpu) { return true; } +static inline bool topology_smt_supported(void) { return false; } +#endif + #endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_TOPOLOGY_H */ diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index b7fd6a72aa76..24bd98401c91 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c @@ -1781,4 +1781,14 @@ void arch_cpu_idle_dead(void) start_secondary_resume(); } +bool topology_smt_supported(void) +{ + return cpu_has_feature(CPU_FTR_SMT); +} + +bool topology_is_primary_thread(unsigned int cpu) +{ + return cpu_thread_in_core(cpu) == 0; +} + #endif diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index b779603978e1..a3e3d5de4d39 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -239,6 +239,7 @@ config PPC select HAVE_STATIC_CALL if PPC32 select HAVE_SYSCALL_TRACEPOINTS select HAVE_VIRT_CPU_ACCOUNTING + select HOTPLUG_SMT if SMP select HUGETLB_PAGE_SIZE_VARIABLE if PPC_BOOK3S_64 && HUGETLB_PAGE select IOMMU_HELPER if PPC64 select IRQ_DOMAIN