All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/4] Support SMT control on arm64
@ 2023-11-21  9:25 ` Yicong Yang
  0 siblings, 0 replies; 16+ messages in thread
From: Yicong Yang @ 2023-11-21  9:25 UTC (permalink / raw
  To: catalin.marinas, will, sudeep.holla, linux-arm-kernel
  Cc: dietmar.eggemann, gregkh, rafael, jonathan.cameron, prime.zeng,
	linuxarm, yangyicong, linux-kernel

From: Yicong Yang <yangyicong@hisilicon.com>

The core CPU control framework supports runtime SMT control which
is not yet supported on arm64. Besides the general vulnerabilities
concerns we want this runtime control on our arm64 server for:

- better single CPU performance in some cases
- saving overall power consumption

This patchset implements it in the following aspects:

- implements the basic support in arch_topology driver
- support retrieve SMT thread number on OF based system
- support retrieve SMT thread number on ACPI based system
- select HOTPLUG_SMT for arm64

Tests has been done on our real ACPI based arm64 server and on
ACPI/OF based QEMU VMs.

The patchset is based on v6.7-rc1.

Change since v3:
- Fix some build and kconfig error reported by kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/linux-arm-kernel/20231114040110.54590-1-yangyicong@huawei.com/

Change since v2:
- Detect SMT thread number at topology build from ACPI/DT, avoid looping CPUs
- Split patches into ACPI/OF/arch_topology path and enable the kconfig for arm64
Link: https://lore.kernel.org/linux-arm-kernel/20231010115335.13862-1-yangyicong@huawei.com/

Yicong Yang (4):
  arch_topology: Support basic SMT control for the driver
  arch_topology: Support SMT control for OF based system
  arm64: topology: Support SMT control on ACPI based system
  arm64: Kconfig: Enable HOTPLUG_SMT

 arch/arm64/Kconfig            |  1 +
 arch/arm64/kernel/topology.c  | 23 ++++++++++++++++++
 drivers/base/arch_topology.c  | 45 +++++++++++++++++++++++++++++++++++
 include/linux/arch_topology.h | 14 +++++++++++
 4 files changed, 83 insertions(+)

-- 
2.24.0


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v4 0/4] Support SMT control on arm64
@ 2023-11-21  9:25 ` Yicong Yang
  0 siblings, 0 replies; 16+ messages in thread
From: Yicong Yang @ 2023-11-21  9:25 UTC (permalink / raw
  To: catalin.marinas, will, sudeep.holla, linux-arm-kernel
  Cc: dietmar.eggemann, gregkh, rafael, jonathan.cameron, prime.zeng,
	linuxarm, yangyicong, linux-kernel

From: Yicong Yang <yangyicong@hisilicon.com>

The core CPU control framework supports runtime SMT control which
is not yet supported on arm64. Besides the general vulnerabilities
concerns we want this runtime control on our arm64 server for:

- better single CPU performance in some cases
- saving overall power consumption

This patchset implements it in the following aspects:

- implements the basic support in arch_topology driver
- support retrieve SMT thread number on OF based system
- support retrieve SMT thread number on ACPI based system
- select HOTPLUG_SMT for arm64

Tests has been done on our real ACPI based arm64 server and on
ACPI/OF based QEMU VMs.

The patchset is based on v6.7-rc1.

Change since v3:
- Fix some build and kconfig error reported by kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/linux-arm-kernel/20231114040110.54590-1-yangyicong@huawei.com/

Change since v2:
- Detect SMT thread number at topology build from ACPI/DT, avoid looping CPUs
- Split patches into ACPI/OF/arch_topology path and enable the kconfig for arm64
Link: https://lore.kernel.org/linux-arm-kernel/20231010115335.13862-1-yangyicong@huawei.com/

Yicong Yang (4):
  arch_topology: Support basic SMT control for the driver
  arch_topology: Support SMT control for OF based system
  arm64: topology: Support SMT control on ACPI based system
  arm64: Kconfig: Enable HOTPLUG_SMT

 arch/arm64/Kconfig            |  1 +
 arch/arm64/kernel/topology.c  | 23 ++++++++++++++++++
 drivers/base/arch_topology.c  | 45 +++++++++++++++++++++++++++++++++++
 include/linux/arch_topology.h | 14 +++++++++++
 4 files changed, 83 insertions(+)

-- 
2.24.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v4 1/4] arch_topology: Support basic SMT control for the driver
  2023-11-21  9:25 ` Yicong Yang
@ 2023-11-21  9:25   ` Yicong Yang
  -1 siblings, 0 replies; 16+ messages in thread
From: Yicong Yang @ 2023-11-21  9:25 UTC (permalink / raw
  To: catalin.marinas, will, sudeep.holla, linux-arm-kernel
  Cc: dietmar.eggemann, gregkh, rafael, jonathan.cameron, prime.zeng,
	linuxarm, yangyicong, linux-kernel

From: Yicong Yang <yangyicong@hisilicon.com>

The core CPU control framework supports runtime SMT control which
is not yet supported by arch_topology driver and thus arch_topology
based architectures. This patch implements it in the following aspects:

- implement topology_is_primary_thread() to indicate the primary thread,
  required by the framework
- architecture code can get/set the SMT thread number by
  topology_smt_{get, set}_num_threads()
- update the SMT thread number for the framework after the topology
  enumerated on arm64, which is also required by the framework

For disabling SMT we'll offline all the secondary threads and
only leave the primary thread. Since we don't have restriction
for primary thread selection, the first thread is chosen as the
primary thread in this implementation.

This patch only implements the basic support for SMT control, which
needs to collabrate with ACPI/OF based topology building to fully
enable the feature. The SMT control will be enabled unless the
correct SMT thread number is set and HOTPLUG_SMT kconfig is selected.

Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
---
 drivers/base/arch_topology.c  | 38 +++++++++++++++++++++++++++++++++++
 include/linux/arch_topology.h | 14 +++++++++++++
 2 files changed, 52 insertions(+)

diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
index b741b5ba82bd..3ed6bdf9460e 100644
--- a/drivers/base/arch_topology.c
+++ b/drivers/base/arch_topology.c
@@ -729,6 +729,36 @@ const struct cpumask *cpu_clustergroup_mask(int cpu)
 	return &cpu_topology[cpu].cluster_sibling;
 }
 
+#ifdef CONFIG_HOTPLUG_SMT
+
+/* Maximum threads number per-Core */
+static unsigned int topology_smt_num_threads = 1;
+
+void __init topology_smt_set_num_threads(unsigned int num_threads)
+{
+	topology_smt_num_threads = num_threads;
+}
+
+unsigned int __init topology_smt_get_num_threads(void)
+{
+	return topology_smt_num_threads;
+}
+
+/*
+ * On SMT Hotplug the primary thread of the SMT won't be disabled. For x86 they
+ * seem to have a primary thread for special purpose. For other arthitectures
+ * like arm64 there's no such restriction for a primary thread, so make the
+ * first thread in the SMT as the primary thread.
+ */
+bool topology_is_primary_thread(unsigned int cpu)
+{
+	if (cpu == cpumask_first(topology_sibling_cpumask(cpu)))
+		return true;
+
+	return false;
+}
+#endif
+
 void update_siblings_masks(unsigned int cpuid)
 {
 	struct cpu_topology *cpu_topo, *cpuid_topo = &cpu_topology[cpuid];
@@ -841,6 +871,14 @@ void __init init_cpu_topology(void)
 		reset_cpu_topology();
 	}
 
+	/*
+	 * By this stage we get to know whether we support SMT or not, update
+	 * the information for the core. We don't support
+	 * CONFIG_SMT_NUM_THREADS_DYNAMIC so make the max_threads == num_threads.
+	 */
+	cpu_smt_set_num_threads(topology_smt_get_num_threads(),
+				topology_smt_get_num_threads());
+
 	for_each_possible_cpu(cpu) {
 		ret = fetch_cache_info(cpu);
 		if (!ret)
diff --git a/include/linux/arch_topology.h b/include/linux/arch_topology.h
index a07b510e7dc5..0367f3a61838 100644
--- a/include/linux/arch_topology.h
+++ b/include/linux/arch_topology.h
@@ -92,6 +92,20 @@ void update_siblings_masks(unsigned int cpu);
 void remove_cpu_topology(unsigned int cpuid);
 void reset_cpu_topology(void);
 int parse_acpi_topology(void);
+
+#ifdef CONFIG_HOTPLUG_SMT
+bool topology_is_primary_thread(unsigned int cpu);
+void topology_smt_set_num_threads(unsigned int num_threads);
+unsigned int topology_smt_get_num_threads(void);
+#else
+static inline bool topology_is_primary_thread(unsigned int cpu) { return false; }
+static inline void topology_smt_set_num_threads(unsigned int num_threads) { }
+static inline unsigned int topology_smt_get_num_threads(void)
+{
+	return 1;
+}
+#endif
+
 #endif
 
 #endif /* _LINUX_ARCH_TOPOLOGY_H_ */
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v4 1/4] arch_topology: Support basic SMT control for the driver
@ 2023-11-21  9:25   ` Yicong Yang
  0 siblings, 0 replies; 16+ messages in thread
From: Yicong Yang @ 2023-11-21  9:25 UTC (permalink / raw
  To: catalin.marinas, will, sudeep.holla, linux-arm-kernel
  Cc: dietmar.eggemann, gregkh, rafael, jonathan.cameron, prime.zeng,
	linuxarm, yangyicong, linux-kernel

From: Yicong Yang <yangyicong@hisilicon.com>

The core CPU control framework supports runtime SMT control which
is not yet supported by arch_topology driver and thus arch_topology
based architectures. This patch implements it in the following aspects:

- implement topology_is_primary_thread() to indicate the primary thread,
  required by the framework
- architecture code can get/set the SMT thread number by
  topology_smt_{get, set}_num_threads()
- update the SMT thread number for the framework after the topology
  enumerated on arm64, which is also required by the framework

For disabling SMT we'll offline all the secondary threads and
only leave the primary thread. Since we don't have restriction
for primary thread selection, the first thread is chosen as the
primary thread in this implementation.

This patch only implements the basic support for SMT control, which
needs to collabrate with ACPI/OF based topology building to fully
enable the feature. The SMT control will be enabled unless the
correct SMT thread number is set and HOTPLUG_SMT kconfig is selected.

Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
---
 drivers/base/arch_topology.c  | 38 +++++++++++++++++++++++++++++++++++
 include/linux/arch_topology.h | 14 +++++++++++++
 2 files changed, 52 insertions(+)

diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
index b741b5ba82bd..3ed6bdf9460e 100644
--- a/drivers/base/arch_topology.c
+++ b/drivers/base/arch_topology.c
@@ -729,6 +729,36 @@ const struct cpumask *cpu_clustergroup_mask(int cpu)
 	return &cpu_topology[cpu].cluster_sibling;
 }
 
+#ifdef CONFIG_HOTPLUG_SMT
+
+/* Maximum threads number per-Core */
+static unsigned int topology_smt_num_threads = 1;
+
+void __init topology_smt_set_num_threads(unsigned int num_threads)
+{
+	topology_smt_num_threads = num_threads;
+}
+
+unsigned int __init topology_smt_get_num_threads(void)
+{
+	return topology_smt_num_threads;
+}
+
+/*
+ * On SMT Hotplug the primary thread of the SMT won't be disabled. For x86 they
+ * seem to have a primary thread for special purpose. For other arthitectures
+ * like arm64 there's no such restriction for a primary thread, so make the
+ * first thread in the SMT as the primary thread.
+ */
+bool topology_is_primary_thread(unsigned int cpu)
+{
+	if (cpu == cpumask_first(topology_sibling_cpumask(cpu)))
+		return true;
+
+	return false;
+}
+#endif
+
 void update_siblings_masks(unsigned int cpuid)
 {
 	struct cpu_topology *cpu_topo, *cpuid_topo = &cpu_topology[cpuid];
@@ -841,6 +871,14 @@ void __init init_cpu_topology(void)
 		reset_cpu_topology();
 	}
 
+	/*
+	 * By this stage we get to know whether we support SMT or not, update
+	 * the information for the core. We don't support
+	 * CONFIG_SMT_NUM_THREADS_DYNAMIC so make the max_threads == num_threads.
+	 */
+	cpu_smt_set_num_threads(topology_smt_get_num_threads(),
+				topology_smt_get_num_threads());
+
 	for_each_possible_cpu(cpu) {
 		ret = fetch_cache_info(cpu);
 		if (!ret)
diff --git a/include/linux/arch_topology.h b/include/linux/arch_topology.h
index a07b510e7dc5..0367f3a61838 100644
--- a/include/linux/arch_topology.h
+++ b/include/linux/arch_topology.h
@@ -92,6 +92,20 @@ void update_siblings_masks(unsigned int cpu);
 void remove_cpu_topology(unsigned int cpuid);
 void reset_cpu_topology(void);
 int parse_acpi_topology(void);
+
+#ifdef CONFIG_HOTPLUG_SMT
+bool topology_is_primary_thread(unsigned int cpu);
+void topology_smt_set_num_threads(unsigned int num_threads);
+unsigned int topology_smt_get_num_threads(void);
+#else
+static inline bool topology_is_primary_thread(unsigned int cpu) { return false; }
+static inline void topology_smt_set_num_threads(unsigned int num_threads) { }
+static inline unsigned int topology_smt_get_num_threads(void)
+{
+	return 1;
+}
+#endif
+
 #endif
 
 #endif /* _LINUX_ARCH_TOPOLOGY_H_ */
-- 
2.24.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v4 2/4] arch_topology: Support SMT control for OF based system
  2023-11-21  9:25 ` Yicong Yang
@ 2023-11-21  9:26   ` Yicong Yang
  -1 siblings, 0 replies; 16+ messages in thread
From: Yicong Yang @ 2023-11-21  9:26 UTC (permalink / raw
  To: catalin.marinas, will, sudeep.holla, linux-arm-kernel
  Cc: dietmar.eggemann, gregkh, rafael, jonathan.cameron, prime.zeng,
	linuxarm, yangyicong, linux-kernel

From: Yicong Yang <yangyicong@hisilicon.com>

On building the topology from the devicetree, we've already
gotten the SMT thread number of each core. Update the largest
SMT thread number to enable the SMT control.

Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
---
 drivers/base/arch_topology.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
index 3ed6bdf9460e..252a436e0c1b 100644
--- a/drivers/base/arch_topology.c
+++ b/drivers/base/arch_topology.c
@@ -526,6 +526,13 @@ static int __init parse_core(struct device_node *core, int package_id,
 		i++;
 	} while (t);
 
+	/*
+	 * We've already gotten threads number in this core, update the SMT
+	 * threads number when necessary.
+	 */
+	if (i > topology_smt_get_num_threads())
+		topology_smt_set_num_threads(i);
+
 	cpu = get_cpu_for_node(core);
 	if (cpu >= 0) {
 		if (!leaf) {
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v4 2/4] arch_topology: Support SMT control for OF based system
@ 2023-11-21  9:26   ` Yicong Yang
  0 siblings, 0 replies; 16+ messages in thread
From: Yicong Yang @ 2023-11-21  9:26 UTC (permalink / raw
  To: catalin.marinas, will, sudeep.holla, linux-arm-kernel
  Cc: dietmar.eggemann, gregkh, rafael, jonathan.cameron, prime.zeng,
	linuxarm, yangyicong, linux-kernel

From: Yicong Yang <yangyicong@hisilicon.com>

On building the topology from the devicetree, we've already
gotten the SMT thread number of each core. Update the largest
SMT thread number to enable the SMT control.

Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
---
 drivers/base/arch_topology.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
index 3ed6bdf9460e..252a436e0c1b 100644
--- a/drivers/base/arch_topology.c
+++ b/drivers/base/arch_topology.c
@@ -526,6 +526,13 @@ static int __init parse_core(struct device_node *core, int package_id,
 		i++;
 	} while (t);
 
+	/*
+	 * We've already gotten threads number in this core, update the SMT
+	 * threads number when necessary.
+	 */
+	if (i > topology_smt_get_num_threads())
+		topology_smt_set_num_threads(i);
+
 	cpu = get_cpu_for_node(core);
 	if (cpu >= 0) {
 		if (!leaf) {
-- 
2.24.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v4 3/4] arm64: topology: Support SMT control on ACPI based system
  2023-11-21  9:25 ` Yicong Yang
@ 2023-11-21  9:26   ` Yicong Yang
  -1 siblings, 0 replies; 16+ messages in thread
From: Yicong Yang @ 2023-11-21  9:26 UTC (permalink / raw
  To: catalin.marinas, will, sudeep.holla, linux-arm-kernel
  Cc: dietmar.eggemann, gregkh, rafael, jonathan.cameron, prime.zeng,
	linuxarm, yangyicong, linux-kernel

From: Yicong Yang <yangyicong@hisilicon.com>

For ACPI we'll build the topology from PPTT and we cannot directly
get the SMT number of each core. Instead using a temporary xarray
to record the SMT number of each core when building the topology
and we can know the largest SMT number in the system. Then we can
notify the arch_topology for supporting SMT control.

Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
---
 arch/arm64/kernel/topology.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c
index 817d788cd866..0dc360c32ec8 100644
--- a/arch/arm64/kernel/topology.c
+++ b/arch/arm64/kernel/topology.c
@@ -17,6 +17,7 @@
 #include <linux/cpufreq.h>
 #include <linux/init.h>
 #include <linux/percpu.h>
+#include <linux/xarray.h>
 
 #include <asm/cpu.h>
 #include <asm/cputype.h>
@@ -43,11 +44,16 @@ static bool __init acpi_cpu_is_threaded(int cpu)
  */
 int __init parse_acpi_topology(void)
 {
+	int thread_num, max_smt_thread_num = 1;
+	struct xarray core_threads;
 	int cpu, topology_id;
+	void *entry;
 
 	if (acpi_disabled)
 		return 0;
 
+	xa_init(&core_threads);
+
 	for_each_possible_cpu(cpu) {
 		topology_id = find_acpi_cpu_topology(cpu, 0);
 		if (topology_id < 0)
@@ -57,6 +63,20 @@ int __init parse_acpi_topology(void)
 			cpu_topology[cpu].thread_id = topology_id;
 			topology_id = find_acpi_cpu_topology(cpu, 1);
 			cpu_topology[cpu].core_id   = topology_id;
+
+			entry = xa_load(&core_threads, topology_id);
+			if (!entry) {
+				xa_store(&core_threads, topology_id,
+					 xa_mk_value(1), GFP_KERNEL);
+			} else {
+				thread_num = xa_to_value(entry);
+				thread_num++;
+				xa_store(&core_threads, topology_id,
+					 xa_mk_value(thread_num), GFP_KERNEL);
+
+				if (thread_num > max_smt_thread_num)
+					max_smt_thread_num = thread_num;
+			}
 		} else {
 			cpu_topology[cpu].thread_id  = -1;
 			cpu_topology[cpu].core_id    = topology_id;
@@ -67,6 +87,9 @@ int __init parse_acpi_topology(void)
 		cpu_topology[cpu].package_id = topology_id;
 	}
 
+	topology_smt_set_num_threads(max_smt_thread_num);
+
+	xa_destroy(&core_threads);
 	return 0;
 }
 #endif
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v4 3/4] arm64: topology: Support SMT control on ACPI based system
@ 2023-11-21  9:26   ` Yicong Yang
  0 siblings, 0 replies; 16+ messages in thread
From: Yicong Yang @ 2023-11-21  9:26 UTC (permalink / raw
  To: catalin.marinas, will, sudeep.holla, linux-arm-kernel
  Cc: dietmar.eggemann, gregkh, rafael, jonathan.cameron, prime.zeng,
	linuxarm, yangyicong, linux-kernel

From: Yicong Yang <yangyicong@hisilicon.com>

For ACPI we'll build the topology from PPTT and we cannot directly
get the SMT number of each core. Instead using a temporary xarray
to record the SMT number of each core when building the topology
and we can know the largest SMT number in the system. Then we can
notify the arch_topology for supporting SMT control.

Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
---
 arch/arm64/kernel/topology.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c
index 817d788cd866..0dc360c32ec8 100644
--- a/arch/arm64/kernel/topology.c
+++ b/arch/arm64/kernel/topology.c
@@ -17,6 +17,7 @@
 #include <linux/cpufreq.h>
 #include <linux/init.h>
 #include <linux/percpu.h>
+#include <linux/xarray.h>
 
 #include <asm/cpu.h>
 #include <asm/cputype.h>
@@ -43,11 +44,16 @@ static bool __init acpi_cpu_is_threaded(int cpu)
  */
 int __init parse_acpi_topology(void)
 {
+	int thread_num, max_smt_thread_num = 1;
+	struct xarray core_threads;
 	int cpu, topology_id;
+	void *entry;
 
 	if (acpi_disabled)
 		return 0;
 
+	xa_init(&core_threads);
+
 	for_each_possible_cpu(cpu) {
 		topology_id = find_acpi_cpu_topology(cpu, 0);
 		if (topology_id < 0)
@@ -57,6 +63,20 @@ int __init parse_acpi_topology(void)
 			cpu_topology[cpu].thread_id = topology_id;
 			topology_id = find_acpi_cpu_topology(cpu, 1);
 			cpu_topology[cpu].core_id   = topology_id;
+
+			entry = xa_load(&core_threads, topology_id);
+			if (!entry) {
+				xa_store(&core_threads, topology_id,
+					 xa_mk_value(1), GFP_KERNEL);
+			} else {
+				thread_num = xa_to_value(entry);
+				thread_num++;
+				xa_store(&core_threads, topology_id,
+					 xa_mk_value(thread_num), GFP_KERNEL);
+
+				if (thread_num > max_smt_thread_num)
+					max_smt_thread_num = thread_num;
+			}
 		} else {
 			cpu_topology[cpu].thread_id  = -1;
 			cpu_topology[cpu].core_id    = topology_id;
@@ -67,6 +87,9 @@ int __init parse_acpi_topology(void)
 		cpu_topology[cpu].package_id = topology_id;
 	}
 
+	topology_smt_set_num_threads(max_smt_thread_num);
+
+	xa_destroy(&core_threads);
 	return 0;
 }
 #endif
-- 
2.24.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v4 4/4] arm64: Kconfig: Enable HOTPLUG_SMT
  2023-11-21  9:25 ` Yicong Yang
@ 2023-11-21  9:26   ` Yicong Yang
  -1 siblings, 0 replies; 16+ messages in thread
From: Yicong Yang @ 2023-11-21  9:26 UTC (permalink / raw
  To: catalin.marinas, will, sudeep.holla, linux-arm-kernel
  Cc: dietmar.eggemann, gregkh, rafael, jonathan.cameron, prime.zeng,
	linuxarm, yangyicong, linux-kernel

From: Yicong Yang <yangyicong@hisilicon.com>

Enable HOTPLUG_SMT for SMT control.

Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
---
 arch/arm64/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 7b071a00425d..9f3f4efc0375 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -233,6 +233,7 @@ config ARM64
 	select HAVE_KRETPROBES
 	select HAVE_GENERIC_VDSO
 	select HOTPLUG_CORE_SYNC_DEAD if HOTPLUG_CPU
+	select HOTPLUG_SMT if (SMP && HOTPLUG_CPU)
 	select IRQ_DOMAIN
 	select IRQ_FORCED_THREADING
 	select KASAN_VMALLOC if KASAN
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v4 4/4] arm64: Kconfig: Enable HOTPLUG_SMT
@ 2023-11-21  9:26   ` Yicong Yang
  0 siblings, 0 replies; 16+ messages in thread
From: Yicong Yang @ 2023-11-21  9:26 UTC (permalink / raw
  To: catalin.marinas, will, sudeep.holla, linux-arm-kernel
  Cc: dietmar.eggemann, gregkh, rafael, jonathan.cameron, prime.zeng,
	linuxarm, yangyicong, linux-kernel

From: Yicong Yang <yangyicong@hisilicon.com>

Enable HOTPLUG_SMT for SMT control.

Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
---
 arch/arm64/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 7b071a00425d..9f3f4efc0375 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -233,6 +233,7 @@ config ARM64
 	select HAVE_KRETPROBES
 	select HAVE_GENERIC_VDSO
 	select HOTPLUG_CORE_SYNC_DEAD if HOTPLUG_CPU
+	select HOTPLUG_SMT if (SMP && HOTPLUG_CPU)
 	select IRQ_DOMAIN
 	select IRQ_FORCED_THREADING
 	select KASAN_VMALLOC if KASAN
-- 
2.24.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH v4 0/4] Support SMT control on arm64
  2023-11-21  9:25 ` Yicong Yang
@ 2023-11-30  6:56   ` Yicong Yang
  -1 siblings, 0 replies; 16+ messages in thread
From: Yicong Yang @ 2023-11-30  6:56 UTC (permalink / raw
  To: catalin.marinas, will, sudeep.holla, linux-arm-kernel
  Cc: yangyicong, dietmar.eggemann, gregkh, rafael, jonathan.cameron,
	prime.zeng, linuxarm, linux-kernel

Hi Sudeep, Catalin, Will and ARM folks,

Any comments? Appreciate for any feedbacks.

Thanks.

On 2023/11/21 17:25, Yicong Yang wrote:
> From: Yicong Yang <yangyicong@hisilicon.com>
> 
> The core CPU control framework supports runtime SMT control which
> is not yet supported on arm64. Besides the general vulnerabilities
> concerns we want this runtime control on our arm64 server for:
> 
> - better single CPU performance in some cases
> - saving overall power consumption
> 
> This patchset implements it in the following aspects:
> 
> - implements the basic support in arch_topology driver
> - support retrieve SMT thread number on OF based system
> - support retrieve SMT thread number on ACPI based system
> - select HOTPLUG_SMT for arm64
> 
> Tests has been done on our real ACPI based arm64 server and on
> ACPI/OF based QEMU VMs.
> 
> The patchset is based on v6.7-rc1.
> 
> Change since v3:
> - Fix some build and kconfig error reported by kernel test robot <lkp@intel.com>
> Link: https://lore.kernel.org/linux-arm-kernel/20231114040110.54590-1-yangyicong@huawei.com/
> 
> Change since v2:
> - Detect SMT thread number at topology build from ACPI/DT, avoid looping CPUs
> - Split patches into ACPI/OF/arch_topology path and enable the kconfig for arm64
> Link: https://lore.kernel.org/linux-arm-kernel/20231010115335.13862-1-yangyicong@huawei.com/
> 
> Yicong Yang (4):
>   arch_topology: Support basic SMT control for the driver
>   arch_topology: Support SMT control for OF based system
>   arm64: topology: Support SMT control on ACPI based system
>   arm64: Kconfig: Enable HOTPLUG_SMT
> 
>  arch/arm64/Kconfig            |  1 +
>  arch/arm64/kernel/topology.c  | 23 ++++++++++++++++++
>  drivers/base/arch_topology.c  | 45 +++++++++++++++++++++++++++++++++++
>  include/linux/arch_topology.h | 14 +++++++++++
>  4 files changed, 83 insertions(+)
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v4 0/4] Support SMT control on arm64
@ 2023-11-30  6:56   ` Yicong Yang
  0 siblings, 0 replies; 16+ messages in thread
From: Yicong Yang @ 2023-11-30  6:56 UTC (permalink / raw
  To: catalin.marinas, will, sudeep.holla, linux-arm-kernel
  Cc: yangyicong, dietmar.eggemann, gregkh, rafael, jonathan.cameron,
	prime.zeng, linuxarm, linux-kernel

Hi Sudeep, Catalin, Will and ARM folks,

Any comments? Appreciate for any feedbacks.

Thanks.

On 2023/11/21 17:25, Yicong Yang wrote:
> From: Yicong Yang <yangyicong@hisilicon.com>
> 
> The core CPU control framework supports runtime SMT control which
> is not yet supported on arm64. Besides the general vulnerabilities
> concerns we want this runtime control on our arm64 server for:
> 
> - better single CPU performance in some cases
> - saving overall power consumption
> 
> This patchset implements it in the following aspects:
> 
> - implements the basic support in arch_topology driver
> - support retrieve SMT thread number on OF based system
> - support retrieve SMT thread number on ACPI based system
> - select HOTPLUG_SMT for arm64
> 
> Tests has been done on our real ACPI based arm64 server and on
> ACPI/OF based QEMU VMs.
> 
> The patchset is based on v6.7-rc1.
> 
> Change since v3:
> - Fix some build and kconfig error reported by kernel test robot <lkp@intel.com>
> Link: https://lore.kernel.org/linux-arm-kernel/20231114040110.54590-1-yangyicong@huawei.com/
> 
> Change since v2:
> - Detect SMT thread number at topology build from ACPI/DT, avoid looping CPUs
> - Split patches into ACPI/OF/arch_topology path and enable the kconfig for arm64
> Link: https://lore.kernel.org/linux-arm-kernel/20231010115335.13862-1-yangyicong@huawei.com/
> 
> Yicong Yang (4):
>   arch_topology: Support basic SMT control for the driver
>   arch_topology: Support SMT control for OF based system
>   arm64: topology: Support SMT control on ACPI based system
>   arm64: Kconfig: Enable HOTPLUG_SMT
> 
>  arch/arm64/Kconfig            |  1 +
>  arch/arm64/kernel/topology.c  | 23 ++++++++++++++++++
>  drivers/base/arch_topology.c  | 45 +++++++++++++++++++++++++++++++++++
>  include/linux/arch_topology.h | 14 +++++++++++
>  4 files changed, 83 insertions(+)
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v4 0/4] Support SMT control on arm64
  2023-11-21  9:25 ` Yicong Yang
@ 2023-12-11 13:16   ` Will Deacon
  -1 siblings, 0 replies; 16+ messages in thread
From: Will Deacon @ 2023-12-11 13:16 UTC (permalink / raw
  To: Yicong Yang
  Cc: catalin.marinas, sudeep.holla, linux-arm-kernel, dietmar.eggemann,
	gregkh, rafael, jonathan.cameron, prime.zeng, linuxarm,
	yangyicong, linux-kernel

On Tue, Nov 21, 2023 at 05:25:58PM +0800, Yicong Yang wrote:
> From: Yicong Yang <yangyicong@hisilicon.com>
> 
> The core CPU control framework supports runtime SMT control which
> is not yet supported on arm64. Besides the general vulnerabilities
> concerns we want this runtime control on our arm64 server for:
> 
> - better single CPU performance in some cases
> - saving overall power consumption
> 
> This patchset implements it in the following aspects:
> 
> - implements the basic support in arch_topology driver
> - support retrieve SMT thread number on OF based system
> - support retrieve SMT thread number on ACPI based system
> - select HOTPLUG_SMT for arm64
> 
> Tests has been done on our real ACPI based arm64 server and on
> ACPI/OF based QEMU VMs.
> 
> The patchset is based on v6.7-rc1.
> 
> Change since v3:
> - Fix some build and kconfig error reported by kernel test robot <lkp@intel.com>
> Link: https://lore.kernel.org/linux-arm-kernel/20231114040110.54590-1-yangyicong@huawei.com/
> 
> Change since v2:
> - Detect SMT thread number at topology build from ACPI/DT, avoid looping CPUs
> - Split patches into ACPI/OF/arch_topology path and enable the kconfig for arm64
> Link: https://lore.kernel.org/linux-arm-kernel/20231010115335.13862-1-yangyicong@huawei.com/
> 
> Yicong Yang (4):
>   arch_topology: Support basic SMT control for the driver
>   arch_topology: Support SMT control for OF based system

Looking at the first two patches you have here, they are incredibly trivial
and feel like they'd be better off implemented as the default behaviour in
the core code so that architectures with additional constraints (e.g. x86)
can override that.

Will

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v4 0/4] Support SMT control on arm64
@ 2023-12-11 13:16   ` Will Deacon
  0 siblings, 0 replies; 16+ messages in thread
From: Will Deacon @ 2023-12-11 13:16 UTC (permalink / raw
  To: Yicong Yang
  Cc: catalin.marinas, sudeep.holla, linux-arm-kernel, dietmar.eggemann,
	gregkh, rafael, jonathan.cameron, prime.zeng, linuxarm,
	yangyicong, linux-kernel

On Tue, Nov 21, 2023 at 05:25:58PM +0800, Yicong Yang wrote:
> From: Yicong Yang <yangyicong@hisilicon.com>
> 
> The core CPU control framework supports runtime SMT control which
> is not yet supported on arm64. Besides the general vulnerabilities
> concerns we want this runtime control on our arm64 server for:
> 
> - better single CPU performance in some cases
> - saving overall power consumption
> 
> This patchset implements it in the following aspects:
> 
> - implements the basic support in arch_topology driver
> - support retrieve SMT thread number on OF based system
> - support retrieve SMT thread number on ACPI based system
> - select HOTPLUG_SMT for arm64
> 
> Tests has been done on our real ACPI based arm64 server and on
> ACPI/OF based QEMU VMs.
> 
> The patchset is based on v6.7-rc1.
> 
> Change since v3:
> - Fix some build and kconfig error reported by kernel test robot <lkp@intel.com>
> Link: https://lore.kernel.org/linux-arm-kernel/20231114040110.54590-1-yangyicong@huawei.com/
> 
> Change since v2:
> - Detect SMT thread number at topology build from ACPI/DT, avoid looping CPUs
> - Split patches into ACPI/OF/arch_topology path and enable the kconfig for arm64
> Link: https://lore.kernel.org/linux-arm-kernel/20231010115335.13862-1-yangyicong@huawei.com/
> 
> Yicong Yang (4):
>   arch_topology: Support basic SMT control for the driver
>   arch_topology: Support SMT control for OF based system

Looking at the first two patches you have here, they are incredibly trivial
and feel like they'd be better off implemented as the default behaviour in
the core code so that architectures with additional constraints (e.g. x86)
can override that.

Will

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v4 0/4] Support SMT control on arm64
  2023-12-11 13:16   ` Will Deacon
@ 2023-12-14 11:39     ` Yicong Yang
  -1 siblings, 0 replies; 16+ messages in thread
From: Yicong Yang @ 2023-12-14 11:39 UTC (permalink / raw
  To: Will Deacon
  Cc: Thomas Gleixner, Peter Zijlstra, catalin.marinas, sudeep.holla,
	linux-arm-kernel, dietmar.eggemann, gregkh, rafael,
	jonathan.cameron, prime.zeng, linuxarm, linux-kernel, yangyicong

Hi Will,

On 2023/12/11 21:16, Will Deacon wrote:
> On Tue, Nov 21, 2023 at 05:25:58PM +0800, Yicong Yang wrote:
>> From: Yicong Yang <yangyicong@hisilicon.com>
>>
>> The core CPU control framework supports runtime SMT control which
>> is not yet supported on arm64. Besides the general vulnerabilities
>> concerns we want this runtime control on our arm64 server for:
>>
>> - better single CPU performance in some cases
>> - saving overall power consumption
>>
>> This patchset implements it in the following aspects:
>>
>> - implements the basic support in arch_topology driver
>> - support retrieve SMT thread number on OF based system
>> - support retrieve SMT thread number on ACPI based system
>> - select HOTPLUG_SMT for arm64
>>
>> Tests has been done on our real ACPI based arm64 server and on
>> ACPI/OF based QEMU VMs.
>>
>> The patchset is based on v6.7-rc1.
>>
>> Change since v3:
>> - Fix some build and kconfig error reported by kernel test robot <lkp@intel.com>
>> Link: https://lore.kernel.org/linux-arm-kernel/20231114040110.54590-1-yangyicong@huawei.com/
>>
>> Change since v2:
>> - Detect SMT thread number at topology build from ACPI/DT, avoid looping CPUs
>> - Split patches into ACPI/OF/arch_topology path and enable the kconfig for arm64
>> Link: https://lore.kernel.org/linux-arm-kernel/20231010115335.13862-1-yangyicong@huawei.com/
>>
>> Yicong Yang (4):
>>   arch_topology: Support basic SMT control for the driver
>>   arch_topology: Support SMT control for OF based system
> 
> Looking at the first two patches you have here, they are incredibly trivial
> and feel like they'd be better off implemented as the default behaviour in
> the core code so that architectures with additional constraints (e.g. x86)
> can override that.
> 

Loop Thomas and Peter in and expect some hint on the SMT HOTPLUG implementation.

Thanks for the comments. I'm a bit uncertain of some points.

Currently the framework requires the architeture provide 2 things to enable HOTPLUG_SMT:
1. In the init stage of the arch code, use cpu_smt_set_num_threads() to tell the framework
   SMT is supported or not and how many threads are within a core.
2. topology_is_primary_thread() to indicate one CPU can be offline or not, when disable SMT.

For the 2nd point, it's possible to provide a weak function in the framework if no special
requirement for the "primary" SMT thread, just make the 1st CPU in a physical core as the
primary thread like what implemented in this patchset for amr64. And let architectures like
x86/powerpc to provides override function for special purpose.

For the 1st point I'm not sure it could/should be done in the framework since we can got this
SMT information only in the init stage after we parsing the topology which is rather architecture
specific. On arm64 we may gain this after parsing the devicetree or ACPI and on x86 they gain
this by CPUID. It's hard to provide a default way for detecting this. So in this patchset the
SMT information is detected separately in the ACPI/OF topology parsing.

Thanks.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v4 0/4] Support SMT control on arm64
@ 2023-12-14 11:39     ` Yicong Yang
  0 siblings, 0 replies; 16+ messages in thread
From: Yicong Yang @ 2023-12-14 11:39 UTC (permalink / raw
  To: Will Deacon
  Cc: Thomas Gleixner, Peter Zijlstra, catalin.marinas, sudeep.holla,
	linux-arm-kernel, dietmar.eggemann, gregkh, rafael,
	jonathan.cameron, prime.zeng, linuxarm, linux-kernel, yangyicong

Hi Will,

On 2023/12/11 21:16, Will Deacon wrote:
> On Tue, Nov 21, 2023 at 05:25:58PM +0800, Yicong Yang wrote:
>> From: Yicong Yang <yangyicong@hisilicon.com>
>>
>> The core CPU control framework supports runtime SMT control which
>> is not yet supported on arm64. Besides the general vulnerabilities
>> concerns we want this runtime control on our arm64 server for:
>>
>> - better single CPU performance in some cases
>> - saving overall power consumption
>>
>> This patchset implements it in the following aspects:
>>
>> - implements the basic support in arch_topology driver
>> - support retrieve SMT thread number on OF based system
>> - support retrieve SMT thread number on ACPI based system
>> - select HOTPLUG_SMT for arm64
>>
>> Tests has been done on our real ACPI based arm64 server and on
>> ACPI/OF based QEMU VMs.
>>
>> The patchset is based on v6.7-rc1.
>>
>> Change since v3:
>> - Fix some build and kconfig error reported by kernel test robot <lkp@intel.com>
>> Link: https://lore.kernel.org/linux-arm-kernel/20231114040110.54590-1-yangyicong@huawei.com/
>>
>> Change since v2:
>> - Detect SMT thread number at topology build from ACPI/DT, avoid looping CPUs
>> - Split patches into ACPI/OF/arch_topology path and enable the kconfig for arm64
>> Link: https://lore.kernel.org/linux-arm-kernel/20231010115335.13862-1-yangyicong@huawei.com/
>>
>> Yicong Yang (4):
>>   arch_topology: Support basic SMT control for the driver
>>   arch_topology: Support SMT control for OF based system
> 
> Looking at the first two patches you have here, they are incredibly trivial
> and feel like they'd be better off implemented as the default behaviour in
> the core code so that architectures with additional constraints (e.g. x86)
> can override that.
> 

Loop Thomas and Peter in and expect some hint on the SMT HOTPLUG implementation.

Thanks for the comments. I'm a bit uncertain of some points.

Currently the framework requires the architeture provide 2 things to enable HOTPLUG_SMT:
1. In the init stage of the arch code, use cpu_smt_set_num_threads() to tell the framework
   SMT is supported or not and how many threads are within a core.
2. topology_is_primary_thread() to indicate one CPU can be offline or not, when disable SMT.

For the 2nd point, it's possible to provide a weak function in the framework if no special
requirement for the "primary" SMT thread, just make the 1st CPU in a physical core as the
primary thread like what implemented in this patchset for amr64. And let architectures like
x86/powerpc to provides override function for special purpose.

For the 1st point I'm not sure it could/should be done in the framework since we can got this
SMT information only in the init stage after we parsing the topology which is rather architecture
specific. On arm64 we may gain this after parsing the devicetree or ACPI and on x86 they gain
this by CPUID. It's hard to provide a default way for detecting this. So in this patchset the
SMT information is detected separately in the ACPI/OF topology parsing.

Thanks.


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2023-12-14 11:41 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-21  9:25 [PATCH v4 0/4] Support SMT control on arm64 Yicong Yang
2023-11-21  9:25 ` Yicong Yang
2023-11-21  9:25 ` [PATCH v4 1/4] arch_topology: Support basic SMT control for the driver Yicong Yang
2023-11-21  9:25   ` Yicong Yang
2023-11-21  9:26 ` [PATCH v4 2/4] arch_topology: Support SMT control for OF based system Yicong Yang
2023-11-21  9:26   ` Yicong Yang
2023-11-21  9:26 ` [PATCH v4 3/4] arm64: topology: Support SMT control on ACPI " Yicong Yang
2023-11-21  9:26   ` Yicong Yang
2023-11-21  9:26 ` [PATCH v4 4/4] arm64: Kconfig: Enable HOTPLUG_SMT Yicong Yang
2023-11-21  9:26   ` Yicong Yang
2023-11-30  6:56 ` [PATCH v4 0/4] Support SMT control on arm64 Yicong Yang
2023-11-30  6:56   ` Yicong Yang
2023-12-11 13:16 ` Will Deacon
2023-12-11 13:16   ` Will Deacon
2023-12-14 11:39   ` Yicong Yang
2023-12-14 11:39     ` Yicong Yang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.