Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

+15 -1
+1 -1
Documentation/admin-guide/kernel-parameters.txt
··· 4585 4585 nosmt [KNL,MIPS,PPC,EARLY] Disable symmetric multithreading (SMT). 4586 4586 Equivalent to smt=1. 4587 4587 4588 - [KNL,X86,PPC,S390] Disable symmetric multithreading (SMT). 4588 + [KNL,LOONGARCH,X86,PPC,S390] Disable symmetric multithreading (SMT). 4589 4589 nosmt=force: Force disable SMT, cannot be undone 4590 4590 via the sysfs control file. 4591 4591
+1
arch/loongarch/Kconfig
··· 186 186 select HAVE_SYSCALL_TRACEPOINTS 187 187 select HAVE_TIF_NOHZ 188 188 select HAVE_VIRT_CPU_ACCOUNTING_GEN 189 + select HOTPLUG_SMT if HOTPLUG_CPU 189 190 select IRQ_FORCED_THREADING 190 191 select IRQ_LOONGARCH_CPU 191 192 select LOCK_MM_AND_FIND_VMA
+13
arch/loongarch/kernel/smp.c
··· 365 365 void __init loongson_prepare_cpus(unsigned int max_cpus) 366 366 { 367 367 int i = 0; 368 + int threads_per_core = 0; 368 369 369 370 parse_acpi_topology(); 370 371 cpu_data[0].global_id = cpu_logical_map(0); 372 + 373 + if (!pptt_enabled) 374 + threads_per_core = 1; 375 + else { 376 + for_each_possible_cpu(i) { 377 + if (cpu_to_node(i) != 0) 378 + continue; 379 + if (cpus_are_siblings(0, i)) 380 + threads_per_core++; 381 + } 382 + } 371 383 372 384 for (i = 0; i < loongson_sysconf.nr_cpus; i++) { 373 385 set_cpu_present(i, true); ··· 387 375 } 388 376 389 377 per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE; 378 + cpu_smt_set_num_threads(threads_per_core, threads_per_core); 390 379 } 391 380 392 381 /*