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

MIPS: Rework smt cmdline parameters

Provide a generic smt parameters interface aligned with s390
to allow users to limit smt usage and threads per core.

It replaced previous undocumented "nothreads" parameter for
smp-cps which is ambiguous and does not cover smp-mt.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>

authored by

Jiaxun Yang and committed by
Thomas Bogendoerfer
96cb8ae2 dfbd992e

+25 -15
+2 -2
Documentation/admin-guide/kernel-parameters.txt
··· 3838 3838 nosmp [SMP] Tells an SMP kernel to act as a UP kernel, 3839 3839 and disable the IO APIC. legacy for "maxcpus=0". 3840 3840 3841 - nosmt [KNL,S390] Disable symmetric multithreading (SMT). 3841 + nosmt [KNL,MIPS,S390] Disable symmetric multithreading (SMT). 3842 3842 Equivalent to smt=1. 3843 3843 3844 3844 [KNL,X86] Disable symmetric multithreading (SMT). ··· 5735 5735 1: Fast pin select (default) 5736 5736 2: ATC IRMode 5737 5737 5738 - smt= [KNL,S390] Set the maximum number of threads (logical 5738 + smt= [KNL,MIPS,S390] Set the maximum number of threads (logical 5739 5739 CPUs) to use per physical CPU on systems capable of 5740 5740 symmetric multithreading (SMT). Will be capped to the 5741 5741 actual hardware limit.
+2
arch/mips/include/asm/smp.h
··· 57 57 /* Mask of CPUs which are currently definitely operating coherently */ 58 58 extern cpumask_t cpu_coherent_mask; 59 59 60 + extern unsigned int smp_max_threads __initdata; 61 + 60 62 extern asmlinkage void smp_bootstrap(void); 61 63 62 64 extern void calculate_cpu_foreign_map(void);
+1 -12
arch/mips/kernel/smp-cps.c
··· 25 25 #include <asm/time.h> 26 26 #include <asm/uasm.h> 27 27 28 - static bool threads_disabled; 29 28 static DECLARE_BITMAP(core_power, NR_CPUS); 30 29 31 30 struct core_boot_config *mips_cps_core_bootcfg; 32 31 33 - static int __init setup_nothreads(char *s) 34 - { 35 - threads_disabled = true; 36 - return 0; 37 - } 38 - early_param("nothreads", setup_nothreads); 39 - 40 32 static unsigned core_vpe_count(unsigned int cluster, unsigned core) 41 33 { 42 - if (threads_disabled) 43 - return 1; 44 - 45 - return mips_cps_numvps(cluster, core); 34 + return min(smp_max_threads, mips_cps_numvps(cluster, core)); 46 35 } 47 36 48 37 static void __init cps_smp_setup(void)
+2 -1
arch/mips/kernel/smp-mt.c
··· 46 46 static unsigned int __init smvp_vpe_init(unsigned int tc, unsigned int mvpconf0, 47 47 unsigned int ncpu) 48 48 { 49 - if (tc > ((mvpconf0 & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT)) 49 + if (tc >= smp_max_threads || 50 + (tc > ((mvpconf0 & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT))) 50 51 return ncpu; 51 52 52 53 /* Deactivate all but VPE 0 */
+18
arch/mips/kernel/smp.c
··· 73 73 74 74 cpumask_t cpu_coherent_mask; 75 75 76 + unsigned int smp_max_threads __initdata = UINT_MAX; 77 + 78 + static int __init early_nosmt(char *s) 79 + { 80 + smp_max_threads = 1; 81 + return 0; 82 + } 83 + early_param("nosmt", early_nosmt); 84 + 85 + static int __init early_smt(char *s) 86 + { 87 + get_option(&s, &smp_max_threads); 88 + /* Ensure at least one thread is available */ 89 + smp_max_threads = clamp_val(smp_max_threads, 1U, UINT_MAX); 90 + return 0; 91 + } 92 + early_param("smt", early_smt); 93 + 76 94 #ifdef CONFIG_GENERIC_IRQ_IPI 77 95 static struct irq_desc *call_desc; 78 96 static struct irq_desc *sched_desc;