mirror of
https://gitee.com/open-loongarch/linux-6.12.git
synced 2026-10-25 12:37:11 +08:00
LoongArch: Add HOTPLUG_SMT implementation
For benchmarking or debugging purpose, we usually want to control SMT via boot parameter and sysfs knobs. So add HOTPLUG_SMT implementation. 1. Boot parameters: nosmt: Disable SMT, can be enabled via sysfs knobs. nosmt=force: Disable SMT, cannot be enabled via sysfs knobs. 2. Runtime sysfs controls: Write "on", "off", "forceoff" or the number of SMT threads (1, 2, ...) to /sys/devices/system/cpu/smt/control. Signed-off-by: Huacai Chen <chenhuacai@loongson.cn> Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn>
This commit is contained in:
@@ -4074,7 +4074,7 @@
|
|||||||
nosmt [KNL,MIPS,PPC,S390,EARLY] Disable symmetric multithreading (SMT).
|
nosmt [KNL,MIPS,PPC,S390,EARLY] Disable symmetric multithreading (SMT).
|
||||||
Equivalent to smt=1.
|
Equivalent to smt=1.
|
||||||
|
|
||||||
[KNL,X86,PPC] Disable symmetric multithreading (SMT).
|
[KNL,LOONGARCH,X86,PPC] Disable symmetric multithreading (SMT).
|
||||||
nosmt=force: Force disable SMT, cannot be undone
|
nosmt=force: Force disable SMT, cannot be undone
|
||||||
via the sysfs control file.
|
via the sysfs control file.
|
||||||
|
|
||||||
|
|||||||
@@ -179,6 +179,7 @@ config LOONGARCH
|
|||||||
select HAVE_SYSCALL_TRACEPOINTS
|
select HAVE_SYSCALL_TRACEPOINTS
|
||||||
select HAVE_TIF_NOHZ
|
select HAVE_TIF_NOHZ
|
||||||
select HAVE_VIRT_CPU_ACCOUNTING_GEN
|
select HAVE_VIRT_CPU_ACCOUNTING_GEN
|
||||||
|
select HOTPLUG_SMT if HOTPLUG_CPU
|
||||||
select IRQ_FORCED_THREADING
|
select IRQ_FORCED_THREADING
|
||||||
select IRQ_LOONGARCH_CPU
|
select IRQ_LOONGARCH_CPU
|
||||||
select LOCK_MM_AND_FIND_VMA
|
select LOCK_MM_AND_FIND_VMA
|
||||||
|
|||||||
@@ -365,16 +365,29 @@ void __init loongson_smp_setup(void)
|
|||||||
void __init loongson_prepare_cpus(unsigned int max_cpus)
|
void __init loongson_prepare_cpus(unsigned int max_cpus)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
int threads_per_core = 0;
|
||||||
|
|
||||||
parse_acpi_topology();
|
parse_acpi_topology();
|
||||||
cpu_data[0].global_id = cpu_logical_map(0);
|
cpu_data[0].global_id = cpu_logical_map(0);
|
||||||
|
|
||||||
|
if (!pptt_enabled)
|
||||||
|
threads_per_core = 1;
|
||||||
|
else {
|
||||||
|
for_each_possible_cpu(i) {
|
||||||
|
if (cpu_to_node(i) != 0)
|
||||||
|
continue;
|
||||||
|
if (cpus_are_siblings(0, i))
|
||||||
|
threads_per_core++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < loongson_sysconf.nr_cpus; i++) {
|
for (i = 0; i < loongson_sysconf.nr_cpus; i++) {
|
||||||
set_cpu_present(i, true);
|
set_cpu_present(i, true);
|
||||||
csr_mail_send(0, __cpu_logical_map[i], 0);
|
csr_mail_send(0, __cpu_logical_map[i], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE;
|
per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE;
|
||||||
|
cpu_smt_set_num_threads(threads_per_core, threads_per_core);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user