[PATCH V10 06/19] riscv: qspinlock: Allow force qspinlock from the command line

guoren at kernel.org guoren at kernel.org
Wed Aug 2 09:46:48 PDT 2023


From: Guo Ren <guoren at linux.alibaba.com>

Allow cmdline to force the kernel to use queued_spinlock when
CONFIG_RISCV_COMBO_SPINLOCKS=y.

Signed-off-by: Guo Ren <guoren at linux.alibaba.com>
Signed-off-by: Guo Ren <guoren at kernel.org>
---
 Documentation/admin-guide/kernel-parameters.txt |  3 +++
 arch/riscv/include/asm/cpufeature.h             |  2 ++
 arch/riscv/kernel/cpufeature.c                  | 15 ++++++++++++++-
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index be40bfbf4380..de6b7ee752cd 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -4666,6 +4666,9 @@
 
 	quiet		[KNL] Disable most log messages
 
+	qspinlock	[RISCV] Forces kernel to use queued_spinlock when
+			CONFIG_RISCV_COMBO_SPINLOCKS=y.
+
 	r128=		[HW,DRM]
 
 	radix_hcall_invalidate=on  [PPC/PSERIES]
diff --git a/arch/riscv/include/asm/cpufeature.h b/arch/riscv/include/asm/cpufeature.h
index 23fed53b8815..2bf0343661da 100644
--- a/arch/riscv/include/asm/cpufeature.h
+++ b/arch/riscv/include/asm/cpufeature.h
@@ -30,4 +30,6 @@ DECLARE_PER_CPU(long, misaligned_access_speed);
 /* Per-cpu ISA extensions. */
 extern struct riscv_isainfo hart_isa[NR_CPUS];
 
+extern bool force_qspinlock;
+
 #endif
diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c
index e65b0e54152d..f8dbbe1bbd34 100644
--- a/arch/riscv/kernel/cpufeature.c
+++ b/arch/riscv/kernel/cpufeature.c
@@ -99,6 +99,17 @@ static bool riscv_isa_extension_check(int id)
 	return true;
 }
 
+#ifdef CONFIG_QUEUED_SPINLOCKS
+bool force_qspinlock = false;
+static int __init force_queued_spinlock(char *p)
+{
+	force_qspinlock = true;
+	pr_info("Force kernel to use queued_spinlock");
+	return 0;
+}
+early_param("qspinlock", force_queued_spinlock);
+#endif
+
 void __init riscv_fill_hwcap(void)
 {
 	struct device_node *node;
@@ -331,7 +342,9 @@ void __init riscv_fill_hwcap(void)
 		 * spinlock value, the only way is to change from queued_spinlock to
 		 * ticket_spinlock, but can not be vice.
 		 */
-		set_bit(RISCV_ISA_EXT_XTICKETLOCK, isainfo->isa);
+		if (!force_qspinlock) {
+			set_bit(RISCV_ISA_EXT_XTICKETLOCK, isainfo->isa);
+		}
 #endif
 
 		/*
-- 
2.36.1




More information about the linux-riscv mailing list