I'm taking over the series Michael sent previously [1] which is smartly
reviewing the initial series I sent [2]. This series is addressing the
comments sent by Thomas and me on the Michael's one.
Here is a short introduction to the issue this series is addressing:
When a new CPU is added, the kernel is activating all its threads. This
leads to weird, but functional, result when adding CPU on a SMT 4 system
for instance.
Here the newly added CPU 1 has 8 threads while the other one has 4 threads
active (system has been booted with the 'smt-enabled=4' kernel option):
ltcden3-lp12:~ # ppc64_cpu --info
Core 0: 0* 1* 2* 3* 4 5 6 7
Core 1: 8* 9* 10* 11* 12* 13* 14* 15*
This mixed SMT level may confused end users and/or some applications.
There is no SMT level recorded in the kernel (common code), neither in user
space, as far as I know. Such a level is helpful when adding new CPU or
when optimizing the energy efficiency (when reactivating CPUs).
When SMP and HOTPLUG_SMT are defined, this series is adding a new SMT level
(cpu_smt_num_threads) and few callbacks allowing the architecture code to
fine control this value, setting a max and a "at boot" level, and
controling whether a thread should be onlined or not.
v3:
Fix a build error in the patch 6/9
v2:
As Thomas suggested,
Reword some commit's description
Remove topology_smt_supported()
Remove topology_smt_threads_supported()
Introduce CONFIG_SMT_NUM_THREADS_DYNAMIC
Remove switch() in __store_smt_control()
Update kernel-parameters.txt
[1] https://lore.kernel.org/linuxppc-dev/20230524155630.794584-1-mpe@ellerman.id.au/
[2] https://lore.kernel.org/linuxppc-dev/20230331153905.31698-1-ldufour@linux.ibm.com/
Laurent Dufour (1):
cpu/SMT: Remove topology_smt_supported()
Michael Ellerman (8):
cpu/SMT: Move SMT prototypes into cpu_smt.h
cpu/SMT: Move smt/control simple exit cases earlier
cpu/SMT: Store the current/max number of threads
cpu/SMT: Create topology_smt_thread_allowed()
cpu/SMT: Allow enabling partial SMT states via sysfs
powerpc/pseries: Initialise CPU hotplug callbacks earlier
powerpc: Add HOTPLUG_SMT support
powerpc/pseries: Honour current SMT state when DLPAR onlining CPUs
.../ABI/testing/sysfs-devices-system-cpu | 1 +
.../admin-guide/kernel-parameters.txt | 4 +-
arch/Kconfig | 3 +
arch/powerpc/Kconfig | 2 +
arch/powerpc/include/asm/topology.h | 15 +++
arch/powerpc/kernel/smp.c | 8 +-
arch/powerpc/platforms/pseries/hotplug-cpu.c | 30 +++--
arch/powerpc/platforms/pseries/pseries.h | 2 +
arch/powerpc/platforms/pseries/setup.c | 2 +
arch/x86/include/asm/topology.h | 4 +-
arch/x86/kernel/cpu/bugs.c | 3 +-
arch/x86/kernel/smpboot.c | 8 --
include/linux/cpu.h | 25 +---
include/linux/cpu_smt.h | 33 +++++
kernel/cpu.c | 118 ++++++++++++++----
15 files changed, 187 insertions(+), 71 deletions(-)
create mode 100644 include/linux/cpu_smt.h
--
2.41.0
From: Michael Ellerman <mpe@ellerman.id.au>
In order to export the cpuhp_smt_control enum as part of the interface
between generic and architecture code, the architecture code needs to
include asm/topology.h.
But that leads to circular header dependencies. So split the enum and
related declarations into a separate header.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
[ldufour: rewording the commit's description]
Signed-off-by: Laurent Dufour <redacted>
---
arch/x86/include/asm/topology.h | 2 ++
include/linux/cpu.h | 25 +------------------------
include/linux/cpu_smt.h | 29 +++++++++++++++++++++++++++++
kernel/cpu.c | 1 +
4 files changed, 33 insertions(+), 24 deletions(-)
create mode 100644 include/linux/cpu_smt.h
From: Michael Ellerman <mpe@ellerman.id.au>
As part of the generic HOTPLUG_SMT code, there is support for disabling
secondary SMT threads at boot time, by passing "nosmt" on the kernel
command line.
The way that is implemented is the secondary threads are brought partly
online, and then taken back offline again. That is done to support x86
CPUs needing certain initialisation done on all threads. However powerpc
has similar needs, see commit d70a54e2d085 ("powerpc/powernv: Ignore
smt-enabled on Power8 and later").
For that to work the powerpc CPU hotplug callbacks need to be registered
before secondary CPUs are brought online, otherwise __cpu_disable()
fails due to smp_ops->cpu_disable being NULL.
So split the basic initialisation into pseries_cpu_hotplug_init() which
can be called early from setup_arch(). The DLPAR related initialisation
can still be done later, because it needs to do allocations.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/platforms/pseries/hotplug-cpu.c | 22 ++++++++++++--------
arch/powerpc/platforms/pseries/pseries.h | 2 ++
arch/powerpc/platforms/pseries/setup.c | 2 ++
3 files changed, 17 insertions(+), 9 deletions(-)
@@ -862,12 +856,22 @@ static int __init pseries_cpu_hotplug_init(void)qcss_tok==RTAS_UNKNOWN_SERVICE){printk(KERN_INFO"CPU Hotplug not supported by firmware ""- disabling.\n");-return0;+return;}smp_ops->cpu_offline_self=pseries_cpu_offline_self;smp_ops->cpu_disable=pseries_cpu_disable;smp_ops->cpu_die=pseries_cpu_die;+}++staticint__initpseries_dlpar_init(void)+{+unsignedintnode;++#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE+ppc_md.cpu_probe=dlpar_cpu_probe;+ppc_md.cpu_release=dlpar_cpu_release;+#endif /* CONFIG_ARCH_CPU_PROBE_RELEASE *//* Processors can be added/removed only on LPAR */if(firmware_has_feature(FW_FEATURE_LPAR)){
@@ -886,4 +890,4 @@ static int __init pseries_cpu_hotplug_init(void)return0;}-machine_arch_initcall(pseries,pseries_cpu_hotplug_init);+machine_arch_initcall(pseries,pseries_dlpar_init);
From: Michael Ellerman <mpe@ellerman.id.au>
Add support for HOTPLUG_SMT, which enables the generic sysfs SMT support
files in /sys/devices/system/cpu/smt, as well as the "nosmt" boot
parameter.
Implement the recently added hooks to allow partial SMT states, allow
any number of threads per core.
Tie the config symbol to HOTPLUG_CPU, which enables it on the major
platforms that support SMT. If there are other platforms that want the
SMT support that can be tweaked in future.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
[ldufour: pass current SMT level to cpu_smt_set_num_threads]
[ldufour: remove topology_smt_supported]
[ldufour: remove topology_smt_threads_supported]
[ldufour: select CONFIG_SMT_NUM_THREADS_DYNAMIC]
[ldufour: update kernel-parameters.txt]
Signed-off-by: Laurent Dufour <redacted>
---
Documentation/admin-guide/kernel-parameters.txt | 4 ++--
arch/powerpc/Kconfig | 2 ++
arch/powerpc/include/asm/topology.h | 15 +++++++++++++++
arch/powerpc/kernel/smp.c | 8 +++++++-
4 files changed, 26 insertions(+), 3 deletions(-)
@@ -3838,10 +3838,10 @@ nosmp [SMP] Tells an SMP kernel to act as a UP kernel, and disable the IO APIC. legacy for "maxcpus=0".- nosmt [KNL,S390] Disable symmetric multithreading (SMT).+ nosmt [KNL,S390,PPC] Disable symmetric multithreading (SMT). Equivalent to smt=1.- [KNL,X86] Disable symmetric multithreading (SMT).+ [KNL,X86,PPC] Disable symmetric multithreading (SMT). nosmt=force: Force disable SMT, cannot be undone via the sysfs control file.
Hi Michael,
Le 29/06/2023 à 16:31, Laurent Dufour a écrit :
quoted hunk
From: Michael Ellerman <mpe@ellerman.id.au>
Add support for HOTPLUG_SMT, which enables the generic sysfs SMT support
files in /sys/devices/system/cpu/smt, as well as the "nosmt" boot
parameter.
Implement the recently added hooks to allow partial SMT states, allow
any number of threads per core.
Tie the config symbol to HOTPLUG_CPU, which enables it on the major
platforms that support SMT. If there are other platforms that want the
SMT support that can be tweaked in future.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
[ldufour: pass current SMT level to cpu_smt_set_num_threads]
[ldufour: remove topology_smt_supported]
[ldufour: remove topology_smt_threads_supported]
[ldufour: select CONFIG_SMT_NUM_THREADS_DYNAMIC]
[ldufour: update kernel-parameters.txt]
Signed-off-by: Laurent Dufour <redacted>
---
Documentation/admin-guide/kernel-parameters.txt | 4 ++--
arch/powerpc/Kconfig | 2 ++
arch/powerpc/include/asm/topology.h | 15 +++++++++++++++
arch/powerpc/kernel/smp.c | 8 +++++++-
4 files changed, 26 insertions(+), 3 deletions(-)
@@ -3838,10 +3838,10 @@ nosmp [SMP] Tells an SMP kernel to act as a UP kernel, and disable the IO APIC. legacy for "maxcpus=0".- nosmt [KNL,S390] Disable symmetric multithreading (SMT).+ nosmt [KNL,S390,PPC] Disable symmetric multithreading (SMT). Equivalent to smt=1.- [KNL,X86] Disable symmetric multithreading (SMT).+ [KNL,X86,PPC] Disable symmetric multithreading (SMT). nosmt=force: Force disable SMT, cannot be undone via the sysfs control file.
I missed that this list should be kept sorted alphabetically.
Could you fix that when applying the series, or should I send a new
version ?
Thanks,
Laurent.
quoted hunk
select HUGETLB_PAGE_SIZE_VARIABLE if PPC_BOOK3S_64 && HUGETLB_PAGE
select IOMMU_HELPER if PPC64
select IRQ_DOMAIN
From: Michael Ellerman <mpe@ellerman.id.au>
Some architectures allows partial SMT states at boot time, ie. when
not all SMT threads are brought online.
To support that the SMT code needs to know the maximum number of SMT
threads, and also the currently configured number.
The architecture code knows the max number of threads, so have the
architecture code pass that value to cpu_smt_set_num_threads(). Note that
although topology_max_smt_threads() exists, it is not configured early
enough to be used here. As architecture, like PowerPC, allows the threads
number to be set through the kernel command line, also pass that value.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
[ldufour: slightly reword the commit message]
[ldufour: rename cpu_smt_check_topology and add a num_threads argument]
Signed-off-by: Laurent Dufour <redacted>
---
arch/x86/kernel/cpu/bugs.c | 3 ++-
include/linux/cpu_smt.h | 8 ++++++--
kernel/cpu.c | 21 ++++++++++++++++++++-
3 files changed, 28 insertions(+), 4 deletions(-)
Since the maximum number of threads is now passed to
cpu_smt_set_num_threads(), checking that value is enough to know if SMT is
supported.
Cc: Michael Ellerman <mpe@ellerman.id.au>
Suggested-by: Thomas Gleixner <redacted>
Signed-off-by: Laurent Dufour <redacted>
---
arch/x86/include/asm/topology.h | 2 --
arch/x86/kernel/smpboot.c | 8 --------
kernel/cpu.c | 2 +-
3 files changed, 1 insertion(+), 11 deletions(-)
@@ -143,7 +143,6 @@ int topology_update_die_map(unsigned int dieid, unsigned int cpu);inttopology_phys_to_logical_pkg(unsignedintpkg);inttopology_phys_to_logical_die(unsignedintdie,unsignedintcpu);booltopology_is_primary_thread(unsignedintcpu);-booltopology_smt_supported(void);#else#define topology_max_packages() (1)staticinlineint
@@ -156,7 +155,6 @@ static inline int topology_phys_to_logical_die(unsigned int die,staticinlineinttopology_max_die_per_package(void){return1;}staticinlineinttopology_max_smt_threads(void){return1;}staticinlinebooltopology_is_primary_thread(unsignedintcpu){returntrue;}-staticinlinebooltopology_smt_supported(void){returnfalse;}#endifstaticinlinevoidarch_fix_phys_package_id(intnum,u32slot)
From: Michael Ellerman <mpe@ellerman.id.au>
Integrate with the generic SMT support, so that when a CPU is DLPAR
onlined it is brought up with the correct SMT mode.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/platforms/pseries/hotplug-cpu.c | 8 ++++++++
1 file changed, 8 insertions(+)
From: Michael Ellerman <mpe@ellerman.id.au>
Add support to the /sys/devices/system/cpu/smt/control interface for
enabling a specified number of SMT threads per core, including partial
SMT states where not all threads are brought online.
The current interface accepts "on" and "off", to enable either 1 or all
SMT threads per core.
This commit allows writing an integer, between 1 and the number of SMT
threads supported by the machine. Writing 1 is a synonym for "off", 2 or
more enables SMT with the specified number of threads.
When reading the file, if all threads are online "on" is returned, to
avoid changing behaviour for existing users. If some other number of
threads is online then the integer value is returned.
Architectures like x86 only supporting 1 thread or all threads, should not
define CONFIG_SMT_NUM_THREADS_DYNAMIC. Architecture supporting partial SMT
states, like PowerPC, should define it.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
[ldufour: slightly reword the commit's description]
[ldufour: remove switch() in __store_smt_control()]
Reported-by: kernel test robot <redacted>
Closes: https://lore.kernel.org/oe-kbuild-all/202306282340.Ihqm0fLA-lkp@intel.com/
[ldufour: fix build issue in control_show()]
Signed-off-by: Laurent Dufour <redacted>
---
.../ABI/testing/sysfs-devices-system-cpu | 1 +
kernel/cpu.c | 60 ++++++++++++++-----
2 files changed, 45 insertions(+), 16 deletions(-)
@@ -555,6 +555,7 @@ Description: Control Symmetric Multi Threading (SMT) ================ ========================================= "on" SMT is enabled "off" SMT is disabled+ "<N>" SMT is enabled with N threads per core. "forceoff" SMT is force disabled. Cannot be changed. "notsupported" SMT is not supported by the CPU "notimplemented" SMT runtime toggling is not
*dev,
{
const char *state = smt_states[cpu_smt_control];
+#ifdef CONFIG_HOTPLUG_SMT
+ /*
+ * If SMT is enabled but not all threads are enabled then
show the
+ * number of threads. If all threads are enabled show "on".
Otherwise
+ * show the state name.
+ */
+ if (cpu_smt_control == CPU_SMT_ENABLED &&
+ cpu_smt_num_threads != cpu_smt_max_threads)
+ return sysfs_emit(buf, "%d\n", cpu_smt_num_threads);
+#endif
+
My understanding is that cpu_smt_control is always set to
CPU_SMT_NOT_IMPLEMENTED when CONFIG_HOTPLUG_SMT is not set, so this
ifdef is not necessary, right?
thanks,
rui
*dev,
{
const char *state = smt_states[cpu_smt_control];
+#ifdef CONFIG_HOTPLUG_SMT
+ /*
+ * If SMT is enabled but not all threads are enabled then
show the
+ * number of threads. If all threads are enabled show "on".
Otherwise
+ * show the state name.
+ */
+ if (cpu_smt_control == CPU_SMT_ENABLED &&
+ cpu_smt_num_threads != cpu_smt_max_threads)
+ return sysfs_emit(buf, "%d\n", cpu_smt_num_threads);
+#endif
+
My understanding is that cpu_smt_control is always set to
CPU_SMT_NOT_IMPLEMENTED when CONFIG_HOTPLUG_SMT is not set, so this
ifdef is not necessary, right?
Hi Rui,
Indeed, cpu_smt_control, cpu_smt_num_threads and cpu_smt_max_threads are
only defined when CONFIG_HOTPLUG_SMT is set. This is the reason for this
#ifdef block.
This has been reported by the kernel test robot testing v2:
https://lore.kernel.org/oe-kbuild-all/202306282340.Ihqm0fLA-lkp@intel.com
Cheers,
Laurent.
From: Michael Ellerman <mpe@ellerman.id.au>
Some architectures allows partial SMT states, ie. 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.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Suggested-by: Thomas Gleixner <redacted>
[ldufour: slightly reword the commit's description]
[ldufour: introduce CONFIG_SMT_NUM_THREADS_DYNAMIC]
Signed-off-by: Laurent Dufour <redacted>
---
arch/Kconfig | 3 +++
kernel/cpu.c | 24 +++++++++++++++++++++++-
2 files changed, 26 insertions(+), 1 deletion(-)
@@ -466,9 +466,23 @@ static int __init smt_cmdline_disable(char *str)}early_param("nosmt",smt_cmdline_disable);+/*+*ForArchicturesupportingpartialSMTstatescheckifthethreadisallowed.+*Otherwisethishasalreadybeencheckedthroughcpu_smt_max_threadswhen+*settingtheSMTlevel.+*/+staticinlineboolcpu_smt_thread_allowed(unsignedintcpu)+{+#ifdef CONFIG_SMT_NUM_THREADS_DYNAMIC+returntopology_smt_thread_allowed(cpu);+#else+returntrue;+#endif+}+staticinlineboolcpu_smt_allowed(unsignedintcpu){-if(cpu_smt_control==CPU_SMT_ENABLED)+if(cpu_smt_control==CPU_SMT_ENABLED&&cpu_smt_thread_allowed(cpu))returntrue;if(topology_is_primary_thread(cpu))
@@ -2283,6 +2297,12 @@ int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval)for_each_online_cpu(cpu){if(topology_is_primary_thread(cpu))continue;+/*+*DisablecanbecalledwithCPU_SMT_ENABLEDwhenchanging+*fromahighertolowernumberofSMTthreadspercore.+*/+if(ctrlval==CPU_SMT_ENABLED&&cpu_smt_thread_allowed(cpu))+continue;ret=cpu_down_maps_locked(cpu,CPUHP_OFFLINE);if(ret)break;
@@ -2317,6 +2337,8 @@ int cpuhp_smt_enable(void)/* Skip online CPUs and CPUs on offline nodes */if(cpu_online(cpu)||!node_online(cpu_to_node(cpu)))continue;+if(!cpu_smt_thread_allowed(cpu))+continue;ret=_cpu_up(cpu,0,CPUHP_ONLINE);if(ret)break;
From: Michael Ellerman <mpe@ellerman.id.au>
Move the simple exit cases, ie. which don't depend on the value written,
earlier in the function. That makes it clearer that regardless of the
input those states can not be transitioned out of.
That does have a user-visible effect, in that the error returned will
now always be EPERM/ENODEV for those states, regardless of the value
written. Previously writing an invalid value would return EINVAL even
when in those states.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
kernel/cpu.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
From: Sachin Sant <hidden> Date: 2023-06-30 13:36:55
On 29-Jun-2023, at 8:01 PM, Laurent Dufour [off-list ref] wrote:
I'm taking over the series Michael sent previously [1] which is smartly
reviewing the initial series I sent [2]. This series is addressing the
comments sent by Thomas and me on the Michael's one.
Here is a short introduction to the issue this series is addressing:
When a new CPU is added, the kernel is activating all its threads. This
leads to weird, but functional, result when adding CPU on a SMT 4 system
for instance.
Here the newly added CPU 1 has 8 threads while the other one has 4 threads
active (system has been booted with the 'smt-enabled=4' kernel option):
ltcden3-lp12:~ # ppc64_cpu --info
Core 0: 0* 1* 2* 3* 4 5 6 7
Core 1: 8* 9* 10* 11* 12* 13* 14* 15*
This mixed SMT level may confused end users and/or some applications.
There is no SMT level recorded in the kernel (common code), neither in user
space, as far as I know. Such a level is helpful when adding new CPU or
when optimizing the energy efficiency (when reactivating CPUs).
When SMP and HOTPLUG_SMT are defined, this series is adding a new SMT level
(cpu_smt_num_threads) and few callbacks allowing the architecture code to
fine control this value, setting a max and a "at boot" level, and
controling whether a thread should be onlined or not.
v3:
Fix a build error in the patch 6/9
Successfully tested the V3 version on a Power10 LPAR. Add/remove of
processor core worked correctly, preserving the SMT level (on a kernel
booted with smt-enabled= parameter)
Laurent (Thanks!) also provided a patch to update the ppc64_cpu &
lparstat utility. With patched ppc64_cpu utility verified that SMT level
changed at runtime was preserved across processor core add (on
a kernel booted without smt-enabled= parameter)
Based on these test results
Tested-by: Sachin Sant <redacted>
- Sachin
On 29-Jun-2023, at 8:01 PM, Laurent Dufour [off-list ref] wrote:
I'm taking over the series Michael sent previously [1] which is smartly
reviewing the initial series I sent [2]. This series is addressing the
comments sent by Thomas and me on the Michael's one.
Here is a short introduction to the issue this series is addressing:
When a new CPU is added, the kernel is activating all its threads. This
leads to weird, but functional, result when adding CPU on a SMT 4 system
for instance.
Here the newly added CPU 1 has 8 threads while the other one has 4 threads
active (system has been booted with the 'smt-enabled=4' kernel option):
ltcden3-lp12:~ # ppc64_cpu --info
Core 0: 0* 1* 2* 3* 4 5 6 7
Core 1: 8* 9* 10* 11* 12* 13* 14* 15*
This mixed SMT level may confused end users and/or some applications.
There is no SMT level recorded in the kernel (common code), neither in user
space, as far as I know. Such a level is helpful when adding new CPU or
when optimizing the energy efficiency (when reactivating CPUs).
When SMP and HOTPLUG_SMT are defined, this series is adding a new SMT level
(cpu_smt_num_threads) and few callbacks allowing the architecture code to
fine control this value, setting a max and a "at boot" level, and
controling whether a thread should be onlined or not.
v3:
Fix a build error in the patch 6/9
Successfully tested the V3 version on a Power10 LPAR. Add/remove of
processor core worked correctly, preserving the SMT level (on a kernel
booted with smt-enabled= parameter)
Laurent (Thanks!) also provided a patch to update the ppc64_cpu &
lparstat utility. With patched ppc64_cpu utility verified that SMT level
changed at runtime was preserved across processor core add (on
a kernel booted without smt-enabled= parameter)
Based on these test results
Tested-by: Sachin Sant <redacted>
Thanks a lot, Sachin!
Once this series is accepted, I'll send the series to update ppc64_cpu.
Hi, Laurent,
I want to test this patch set and found that it does not apply on top
of latest usptream git, because of some changes in this merge window,
so better rebase.
thanks,
rui
On Thu, 2023-06-29 at 16:31 +0200, Laurent Dufour wrote:
I'm taking over the series Michael sent previously [1] which is
smartly
reviewing the initial series I sent [2]. This series is addressing
the
comments sent by Thomas and me on the Michael's one.
Here is a short introduction to the issue this series is addressing:
When a new CPU is added, the kernel is activating all its threads.
This
leads to weird, but functional, result when adding CPU on a SMT 4
system
for instance.
Here the newly added CPU 1 has 8 threads while the other one has 4
threads
active (system has been booted with the 'smt-enabled=4' kernel
option):
ltcden3-lp12:~ # ppc64_cpu --info
Core 0: 0* 1* 2* 3* 4 5 6 7
Core 1: 8* 9* 10* 11* 12* 13* 14* 15*
This mixed SMT level may confused end users and/or some applications.
There is no SMT level recorded in the kernel (common code), neither
in user
space, as far as I know. Such a level is helpful when adding new CPU
or
when optimizing the energy efficiency (when reactivating CPUs).
When SMP and HOTPLUG_SMT are defined, this series is adding a new SMT
level
(cpu_smt_num_threads) and few callbacks allowing the architecture
code to
fine control this value, setting a max and a "at boot" level, and
controling whether a thread should be onlined or not.
v3:
Fix a build error in the patch 6/9
v2:
As Thomas suggested,
Reword some commit's description
Remove topology_smt_supported()
Remove topology_smt_threads_supported()
Introduce CONFIG_SMT_NUM_THREADS_DYNAMIC
Remove switch() in __store_smt_control()
Update kernel-parameters.txt
[1]
https://lore.kernel.org/linuxppc-dev/20230524155630.794584-1-mpe@ellerman.id.au/
[2]
https://lore.kernel.org/linuxppc-dev/20230331153905.31698-1-ldufour@linux.ibm.com/
Laurent Dufour (1):
cpu/SMT: Remove topology_smt_supported()
Michael Ellerman (8):
cpu/SMT: Move SMT prototypes into cpu_smt.h
cpu/SMT: Move smt/control simple exit cases earlier
cpu/SMT: Store the current/max number of threads
cpu/SMT: Create topology_smt_thread_allowed()
cpu/SMT: Allow enabling partial SMT states via sysfs
powerpc/pseries: Initialise CPU hotplug callbacks earlier
powerpc: Add HOTPLUG_SMT support
powerpc/pseries: Honour current SMT state when DLPAR onlining CPUs
.../ABI/testing/sysfs-devices-system-cpu | 1 +
.../admin-guide/kernel-parameters.txt | 4 +-
arch/Kconfig | 3 +
arch/powerpc/Kconfig | 2 +
arch/powerpc/include/asm/topology.h | 15 +++
arch/powerpc/kernel/smp.c | 8 +-
arch/powerpc/platforms/pseries/hotplug-cpu.c | 30 +++--
arch/powerpc/platforms/pseries/pseries.h | 2 +
arch/powerpc/platforms/pseries/setup.c | 2 +
arch/x86/include/asm/topology.h | 4 +-
arch/x86/kernel/cpu/bugs.c | 3 +-
arch/x86/kernel/smpboot.c | 8 --
include/linux/cpu.h | 25 +---
include/linux/cpu_smt.h | 33 +++++
kernel/cpu.c | 118 ++++++++++++++--
--
15 files changed, 187 insertions(+), 71 deletions(-)
create mode 100644 include/linux/cpu_smt.h
Hi, Laurent,
I want to test this patch set and found that it does not apply on top
of latest usptream git, because of some changes in this merge window,
so better rebase.
Hi Rui,
Thanks for your interest for this series.
The latest Thomas's changes came into the PowerPC next branch.
I'm working on a rebase.
Cheers,
Laurent.
thanks,
rui
On Thu, 2023-06-29 at 16:31 +0200, Laurent Dufour wrote:
quoted
I'm taking over the series Michael sent previously [1] which is
smartly
reviewing the initial series I sent [2]. This series is addressing
the
comments sent by Thomas and me on the Michael's one.
Here is a short introduction to the issue this series is addressing:
When a new CPU is added, the kernel is activating all its threads.
This
leads to weird, but functional, result when adding CPU on a SMT 4
system
for instance.
Here the newly added CPU 1 has 8 threads while the other one has 4
threads
active (system has been booted with the 'smt-enabled=4' kernel
option):
ltcden3-lp12:~ # ppc64_cpu --info
Core 0: 0* 1* 2* 3* 4 5 6 7
Core 1: 8* 9* 10* 11* 12* 13* 14* 15*
This mixed SMT level may confused end users and/or some applications.
There is no SMT level recorded in the kernel (common code), neither
in user
space, as far as I know. Such a level is helpful when adding new CPU
or
when optimizing the energy efficiency (when reactivating CPUs).
When SMP and HOTPLUG_SMT are defined, this series is adding a new SMT
level
(cpu_smt_num_threads) and few callbacks allowing the architecture
code to
fine control this value, setting a max and a "at boot" level, and
controling whether a thread should be onlined or not.
v3:
Fix a build error in the patch 6/9
v2:
As Thomas suggested,
Reword some commit's description
Remove topology_smt_supported()
Remove topology_smt_threads_supported()
Introduce CONFIG_SMT_NUM_THREADS_DYNAMIC
Remove switch() in __store_smt_control()
Update kernel-parameters.txt
[1]
https://lore.kernel.org/linuxppc-dev/20230524155630.794584-1-mpe@ellerman.id.au/
[2]
https://lore.kernel.org/linuxppc-dev/20230331153905.31698-1-ldufour@linux.ibm.com/
Laurent Dufour (1):
cpu/SMT: Remove topology_smt_supported()
Michael Ellerman (8):
cpu/SMT: Move SMT prototypes into cpu_smt.h
cpu/SMT: Move smt/control simple exit cases earlier
cpu/SMT: Store the current/max number of threads
cpu/SMT: Create topology_smt_thread_allowed()
cpu/SMT: Allow enabling partial SMT states via sysfs
powerpc/pseries: Initialise CPU hotplug callbacks earlier
powerpc: Add HOTPLUG_SMT support
powerpc/pseries: Honour current SMT state when DLPAR onlining CPUs
.../ABI/testing/sysfs-devices-system-cpu | 1 +
.../admin-guide/kernel-parameters.txt | 4 +-
arch/Kconfig | 3 +
arch/powerpc/Kconfig | 2 +
arch/powerpc/include/asm/topology.h | 15 +++
arch/powerpc/kernel/smp.c | 8 +-
arch/powerpc/platforms/pseries/hotplug-cpu.c | 30 +++--
arch/powerpc/platforms/pseries/pseries.h | 2 +
arch/powerpc/platforms/pseries/setup.c | 2 +
arch/x86/include/asm/topology.h | 4 +-
arch/x86/kernel/cpu/bugs.c | 3 +-
arch/x86/kernel/smpboot.c | 8 --
include/linux/cpu.h | 25 +---
include/linux/cpu_smt.h | 33 +++++
kernel/cpu.c | 118 ++++++++++++++--
--
15 files changed, 187 insertions(+), 71 deletions(-)
create mode 100644 include/linux/cpu_smt.h