summaryrefslogtreecommitdiffstats
path: root/arch/mips
diff options
context:
space:
mode:
authorJiaxun Yang <jiaxun.yang@flygoat.com>2023-05-21 23:31:22 +0100
committerThomas Bogendoerfer <tsbogend@alpha.franken.de>2023-06-09 10:34:14 +0200
commit96cb8ae28c652e7ef0633b1c0786eb0f529ed516 (patch)
tree3490ae910dca2655c0fd16b9ece2d4974dc9e886 /arch/mips
parentdfbd992e0ef2319b869bf69fe649d34d2dc49e4b (diff)
downloadlinux-stable-96cb8ae28c652e7ef0633b1c0786eb0f529ed516.tar.gz
linux-stable-96cb8ae28c652e7ef0633b1c0786eb0f529ed516.tar.bz2
linux-stable-96cb8ae28c652e7ef0633b1c0786eb0f529ed516.zip
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>
Diffstat (limited to 'arch/mips')
-rw-r--r--arch/mips/include/asm/smp.h2
-rw-r--r--arch/mips/kernel/smp-cps.c13
-rw-r--r--arch/mips/kernel/smp-mt.c3
-rw-r--r--arch/mips/kernel/smp.c18
4 files changed, 23 insertions, 13 deletions
diff --git a/arch/mips/include/asm/smp.h b/arch/mips/include/asm/smp.h
index aab8981bc32c..a40d8c0e4b87 100644
--- a/arch/mips/include/asm/smp.h
+++ b/arch/mips/include/asm/smp.h
@@ -57,6 +57,8 @@ extern int __cpu_logical_map[NR_CPUS];
/* Mask of CPUs which are currently definitely operating coherently */
extern cpumask_t cpu_coherent_mask;
+extern unsigned int smp_max_threads __initdata;
+
extern asmlinkage void smp_bootstrap(void);
extern void calculate_cpu_foreign_map(void);
diff --git a/arch/mips/kernel/smp-cps.c b/arch/mips/kernel/smp-cps.c
index 62f677b2306f..bea6a13ea464 100644
--- a/arch/mips/kernel/smp-cps.c
+++ b/arch/mips/kernel/smp-cps.c
@@ -25,24 +25,13 @@
#include <asm/time.h>
#include <asm/uasm.h>
-static bool threads_disabled;
static DECLARE_BITMAP(core_power, NR_CPUS);
struct core_boot_config *mips_cps_core_bootcfg;
-static int __init setup_nothreads(char *s)
-{
- threads_disabled = true;
- return 0;
-}
-early_param("nothreads", setup_nothreads);
-
static unsigned core_vpe_count(unsigned int cluster, unsigned core)
{
- if (threads_disabled)
- return 1;
-
- return mips_cps_numvps(cluster, core);
+ return min(smp_max_threads, mips_cps_numvps(cluster, core));
}
static void __init cps_smp_setup(void)
diff --git a/arch/mips/kernel/smp-mt.c b/arch/mips/kernel/smp-mt.c
index 5f04a0141068..7729cc733421 100644
--- a/arch/mips/kernel/smp-mt.c
+++ b/arch/mips/kernel/smp-mt.c
@@ -46,7 +46,8 @@ static void __init smvp_copy_vpe_config(void)
static unsigned int __init smvp_vpe_init(unsigned int tc, unsigned int mvpconf0,
unsigned int ncpu)
{
- if (tc > ((mvpconf0 & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT))
+ if (tc >= smp_max_threads ||
+ (tc > ((mvpconf0 & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT)))
return ncpu;
/* Deactivate all but VPE 0 */
diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
index 1d93b85271ba..280251ea8319 100644
--- a/arch/mips/kernel/smp.c
+++ b/arch/mips/kernel/smp.c
@@ -73,6 +73,24 @@ static cpumask_t cpu_core_setup_map;
cpumask_t cpu_coherent_mask;
+unsigned int smp_max_threads __initdata = UINT_MAX;
+
+static int __init early_nosmt(char *s)
+{
+ smp_max_threads = 1;
+ return 0;
+}
+early_param("nosmt", early_nosmt);
+
+static int __init early_smt(char *s)
+{
+ get_option(&s, &smp_max_threads);
+ /* Ensure at least one thread is available */
+ smp_max_threads = clamp_val(smp_max_threads, 1U, UINT_MAX);
+ return 0;
+}
+early_param("smt", early_smt);
+
#ifdef CONFIG_GENERIC_IRQ_IPI
static struct irq_desc *call_desc;
static struct irq_desc *sched_desc;