Skip to content

Commit 96cb8ae

Browse files
FlyGoattsbogend
authored andcommitted
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 <[email protected]> Signed-off-by: Thomas Bogendoerfer <[email protected]>
1 parent dfbd992 commit 96cb8ae

File tree

5 files changed

+25
-15
lines changed

5 files changed

+25
-15
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3838,7 +3838,7 @@
38383838
nosmp [SMP] Tells an SMP kernel to act as a UP kernel,
38393839
and disable the IO APIC. legacy for "maxcpus=0".
38403840

3841-
nosmt [KNL,S390] Disable symmetric multithreading (SMT).
3841+
nosmt [KNL,MIPS,S390] Disable symmetric multithreading (SMT).
38423842
Equivalent to smt=1.
38433843

38443844
[KNL,X86] Disable symmetric multithreading (SMT).
@@ -5735,7 +5735,7 @@
57355735
1: Fast pin select (default)
57365736
2: ATC IRMode
57375737

5738-
smt= [KNL,S390] Set the maximum number of threads (logical
5738+
smt= [KNL,MIPS,S390] Set the maximum number of threads (logical
57395739
CPUs) to use per physical CPU on systems capable of
57405740
symmetric multithreading (SMT). Will be capped to the
57415741
actual hardware limit.

arch/mips/include/asm/smp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ extern int __cpu_logical_map[NR_CPUS];
5757
/* Mask of CPUs which are currently definitely operating coherently */
5858
extern cpumask_t cpu_coherent_mask;
5959

60+
extern unsigned int smp_max_threads __initdata;
61+
6062
extern asmlinkage void smp_bootstrap(void);
6163

6264
extern void calculate_cpu_foreign_map(void);

arch/mips/kernel/smp-cps.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,13 @@
2525
#include <asm/time.h>
2626
#include <asm/uasm.h>
2727

28-
static bool threads_disabled;
2928
static DECLARE_BITMAP(core_power, NR_CPUS);
3029

3130
struct core_boot_config *mips_cps_core_bootcfg;
3231

33-
static int __init setup_nothreads(char *s)
34-
{
35-
threads_disabled = true;
36-
return 0;
37-
}
38-
early_param("nothreads", setup_nothreads);
39-
4032
static unsigned core_vpe_count(unsigned int cluster, unsigned core)
4133
{
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));
4635
}
4736

4837
static void __init cps_smp_setup(void)

arch/mips/kernel/smp-mt.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ static void __init smvp_copy_vpe_config(void)
4646
static unsigned int __init smvp_vpe_init(unsigned int tc, unsigned int mvpconf0,
4747
unsigned int ncpu)
4848
{
49-
if (tc > ((mvpconf0 & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT))
49+
if (tc >= smp_max_threads ||
50+
(tc > ((mvpconf0 & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT)))
5051
return ncpu;
5152

5253
/* Deactivate all but VPE 0 */

arch/mips/kernel/smp.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,24 @@ static cpumask_t cpu_core_setup_map;
7373

7474
cpumask_t cpu_coherent_mask;
7575

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+
7694
#ifdef CONFIG_GENERIC_IRQ_IPI
7795
static struct irq_desc *call_desc;
7896
static struct irq_desc *sched_desc;

0 commit comments

Comments
 (0)