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

powerpc: Correct smt_enabled=X boot option for > 2 threads per core

The 'smt_enabled=X' boot option does not handle values of X > 2.
For Power 7 processors with smt modes of 0,1,2,3, and 4 this does
not work. This patch allows the smt_enabled option to be set to
any value limited to a max equal to the number of threads per
core.

Signed-off-by: Nathan Fontenot <nfont@austin.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

authored by

Nathan Fontenot and committed by
Benjamin Herrenschmidt
954e6da5 1afb56cf

+40 -28
+33 -24
arch/powerpc/kernel/setup_64.c
··· 95 95 96 96 #ifdef CONFIG_SMP 97 97 98 - static int smt_enabled_cmdline; 98 + static char *smt_enabled_cmdline; 99 99 100 100 /* Look for ibm,smt-enabled OF option */ 101 101 static void check_smt_enabled(void) ··· 103 103 struct device_node *dn; 104 104 const char *smt_option; 105 105 106 + /* Default to enabling all threads */ 107 + smt_enabled_at_boot = threads_per_core; 108 + 106 109 /* Allow the command line to overrule the OF option */ 107 - if (smt_enabled_cmdline) 108 - return; 110 + if (smt_enabled_cmdline) { 111 + if (!strcmp(smt_enabled_cmdline, "on")) 112 + smt_enabled_at_boot = threads_per_core; 113 + else if (!strcmp(smt_enabled_cmdline, "off")) 114 + smt_enabled_at_boot = 0; 115 + else { 116 + long smt; 117 + int rc; 109 118 110 - dn = of_find_node_by_path("/options"); 119 + rc = strict_strtol(smt_enabled_cmdline, 10, &smt); 120 + if (!rc) 121 + smt_enabled_at_boot = 122 + min(threads_per_core, (int)smt); 123 + } 124 + } else { 125 + dn = of_find_node_by_path("/options"); 126 + if (dn) { 127 + smt_option = of_get_property(dn, "ibm,smt-enabled", 128 + NULL); 111 129 112 - if (dn) { 113 - smt_option = of_get_property(dn, "ibm,smt-enabled", NULL); 130 + if (smt_option) { 131 + if (!strcmp(smt_option, "on")) 132 + smt_enabled_at_boot = threads_per_core; 133 + else if (!strcmp(smt_option, "off")) 134 + smt_enabled_at_boot = 0; 135 + } 114 136 115 - if (smt_option) { 116 - if (!strcmp(smt_option, "on")) 117 - smt_enabled_at_boot = 1; 118 - else if (!strcmp(smt_option, "off")) 119 - smt_enabled_at_boot = 0; 120 - } 121 - } 137 + of_node_put(dn); 138 + } 139 + } 122 140 } 123 141 124 142 /* Look for smt-enabled= cmdline option */ 125 143 static int __init early_smt_enabled(char *p) 126 144 { 127 - smt_enabled_cmdline = 1; 128 - 129 - if (!p) 130 - return 0; 131 - 132 - if (!strcmp(p, "on") || !strcmp(p, "1")) 133 - smt_enabled_at_boot = 1; 134 - else if (!strcmp(p, "off") || !strcmp(p, "0")) 135 - smt_enabled_at_boot = 0; 136 - 145 + smt_enabled_cmdline = p; 137 146 return 0; 138 147 } 139 148 early_param("smt-enabled", early_smt_enabled); ··· 389 380 */ 390 381 xmon_setup(); 391 382 392 - check_smt_enabled(); 393 383 smp_setup_cpu_maps(); 384 + check_smt_enabled(); 394 385 395 386 #ifdef CONFIG_SMP 396 387 /* Release secondary cpus out of their spinloops at 0x60 now that
+7 -4
arch/powerpc/platforms/pseries/smp.c
··· 182 182 /* Special case - we inhibit secondary thread startup 183 183 * during boot if the user requests it. 184 184 */ 185 - if (system_state < SYSTEM_RUNNING && 186 - cpu_has_feature(CPU_FTR_SMT) && 187 - !smt_enabled_at_boot && cpu_thread_in_core(nr) != 0) 188 - return 0; 185 + if (system_state < SYSTEM_RUNNING && cpu_has_feature(CPU_FTR_SMT)) { 186 + if (!smt_enabled_at_boot && cpu_thread_in_core(nr) != 0) 187 + return 0; 188 + if (smt_enabled_at_boot 189 + && cpu_thread_in_core(nr) >= smt_enabled_at_boot) 190 + return 0; 191 + } 189 192 190 193 return 1; 191 194 }