Unverified Commit a1ff0c9f authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!12996 【OLK-5.10】Support SMT control on arm64

Merge Pull Request from: @caodongxia 
 
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:

Jie Liu (1):
  config: enable CONFIG_HOTPLUG_SMT for arm64

Michael Ellerman (2):
  cpu/SMT: Move SMT prototypes into cpu_smt.h
  cpu/SMT: Store the current/max number of threads

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/configs/openeuler_defconfig |  1 +
 arch/arm64/kernel/topology.c           | 23 +++++++++++++
 arch/x86/include/asm/topology.h        |  2 ++
 arch/x86/kernel/cpu/common.c           |  2 +-
 drivers/base/arch_topology.c           | 46 ++++++++++++++++++++++++++
 include/linux/arch_topology.h          | 14 ++++++++
 include/linux/cpu.h                    | 25 +-------------
 include/linux/cpu_smt.h                | 33 ++++++++++++++++++
 kernel/cpu.c                           | 24 ++++++++++++--
 10 files changed, 144 insertions(+), 27 deletions(-)
 create mode 100644 include/linux/cpu_smt.h

issue: https://gitee.com/caodongxia/kernel/commits/OLK-5.10
reference: https://gitee.com/openeuler/kernel/pulls/3745

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

 
 
Link:https://gitee.com/openeuler/kernel/pulls/12996

 

Reviewed-by: default avatarXie XiuQi <xiexiuqi@huawei.com>
Reviewed-by: default avatarZhang Jianhua <chris.zjh@huawei.com>
Reviewed-by: default avatarZucheng Zheng <zhengzucheng@huawei.com>
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
parents 99db8adc 9a8a34f6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -198,6 +198,7 @@ config ARM64
	select HAVE_GENERIC_VDSO
	select HOLES_IN_ZONE
	select IOMMU_DMA if IOMMU_SUPPORT
	select HOTPLUG_SMT if (SMP && HOTPLUG_CPU)
	select IRQ_DOMAIN
	select IRQ_FORCED_THREADING
	select KASAN_VMALLOC if KASAN_GENERIC
+1 −0
Original line number Diff line number Diff line
@@ -826,6 +826,7 @@ CONFIG_QUICK_KEXEC=y
CONFIG_HAVE_IMA_KEXEC=y
CONFIG_ARCH_WANT_RESERVE_CRASH_KERNEL=y
CONFIG_OPROFILE_NMI_TIMER=y
CONFIG_HOTPLUG_SMT=y
CONFIG_KPROBES=y
CONFIG_JUMP_LABEL=y
# CONFIG_STATIC_KEYS_SELFTEST is not set
+23 −0
Original line number Diff line number Diff line
@@ -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>
@@ -90,11 +91,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, ret;
	void *entry;

	if (acpi_disabled)
		return 0;

	xa_init(&core_threads);

	ret = acpi_pptt_init();
	if (ret)
		return ret;
@@ -110,6 +116,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;
@@ -132,6 +152,9 @@ int __init parse_acpi_topology(void)
		}
	}

	topology_smt_set_num_threads(max_smt_thread_num);

	xa_destroy(&core_threads);
	return 0;
}
#endif
+2 −0
Original line number Diff line number Diff line
@@ -135,6 +135,8 @@ static inline int topology_max_smt_threads(void)
	return __max_smt_threads;
}

#include <linux/cpu_smt.h>

int topology_update_package_map(unsigned int apicid, unsigned int cpu);
int topology_update_die_map(unsigned int dieid, unsigned int cpu);
int topology_phys_to_logical_pkg(unsigned int pkg);
+1 −1
Original line number Diff line number Diff line
@@ -2262,7 +2262,7 @@ void __init arch_cpu_finalize_init(void)
	 * identify_boot_cpu() initialized SMT support information, let the
	 * core code know.
	 */
	cpu_smt_check_topology();
	cpu_smt_set_num_threads(smp_num_siblings, smp_num_siblings);

	if (!IS_ENABLED(CONFIG_SMP)) {
		pr_info("CPU: ");
Loading