aboutsummaryrefslogtreecommitdiffstats
diff options
authorBoqun Feng <boqun.feng@gmail.com>2025-04-01 06:48:48 -0700
committerBoqun Feng <boqun.feng@gmail.com>2025-04-12 22:35:43 -0700
commitaafd8dd2fa350cbc7af6ffcf231ded2f9e4e18c8 (patch)
tree4b83423005282485a08f5078538ce6addd236f66
parent78f1e1c81b5137bb70df714ded3be5e8946a3c0b (diff)
downloadlinux-dev-shazptr.tar.gz
WIP: shazptr: Add torture test for shazptrdev-shazptr
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
-rw-r--r--kernel/locking/Makefile1
-rw-r--r--kernel/locking/shazptrtorture.c37
-rw-r--r--lib/Kconfig.debug15
-rwxr-xr-xtools/testing/selftests/rcutorture/bin/kvm.sh4
4 files changed, 55 insertions, 2 deletions
diff --git a/kernel/locking/Makefile b/kernel/locking/Makefile
index 1517076c98ec20..8ab71673d77c1e 100644
--- a/kernel/locking/Makefile
+++ b/kernel/locking/Makefile
@@ -31,5 +31,6 @@ obj-$(CONFIG_DEBUG_SPINLOCK) += spinlock.o
obj-$(CONFIG_DEBUG_SPINLOCK) += spinlock_debug.o
obj-$(CONFIG_QUEUED_RWLOCKS) += qrwlock.o
obj-$(CONFIG_LOCK_TORTURE_TEST) += locktorture.o
+obj-$(CONFIG_SHAZPTR_TORTURE_TEST) += shazptrtorture.o
obj-$(CONFIG_WW_MUTEX_SELFTEST) += test-ww_mutex.o
obj-$(CONFIG_LOCK_EVENT_COUNTS) += lock_events.o
diff --git a/kernel/locking/shazptrtorture.c b/kernel/locking/shazptrtorture.c
new file mode 100644
index 00000000000000..380823ec053555
--- /dev/null
+++ b/kernel/locking/shazptrtorture.c
@@ -0,0 +1,37 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Module-based torture test facility for shazptr
+ *
+ * Copyright (C) Microsoft Corporation, 2025
+ *
+ * Author: Boqun Feng <boqun.feng@gmail.com>
+ * Based on kernel/rcu/torture.c.
+ */
+
+#define pr_fmt(fmt) fmt
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/torture.h>
+
+MODULE_DESCRIPTION("torture test facility for locking");
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Boqun Feng <boqun.feng@gmail.com>");
+
+torture_param(int, verbose, 1, "Enable verbose debugging printk()s");
+
+static int __init shazptr_torture_init(void)
+{
+ if (!torture_init_begin("shazptr", verbose))
+ return -EBUSY;
+ torture_init_end();
+ return 0;
+}
+
+static void shazptr_torture_cleanup(void)
+{
+}
+
+module_init(shazptr_torture_init);
+module_exit(shazptr_torture_cleanup);
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 9fe4d8dfe57829..33236bd50a57d9 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -1607,6 +1607,21 @@ config LOCK_TORTURE_TEST
Say M if you want these torture tests to build as a module.
Say N if you are unsure.
+config SHAZPTR_TORTURE_TEST
+ tristate "torture tests for simple hazard pointers"
+ depends on DEBUG_KERNEL
+ select TORTURE_TEST
+ help
+ This option provides a kernel module that runs torture tests
+ on simple hazard pointers (shazptr) primitives. The kernel module
+ may be built after the fact on the running kernel to be tested, if
+ desired.
+
+ Say Y here if you want kernel shazptr torture tests to be built into
+ the kernel.
+ Say M if you want these torture tests to build as a module.
+ Say N if you are unsure.
+
config WW_MUTEX_SELFTEST
tristate "Wait/wound mutex selftests"
help
diff --git a/tools/testing/selftests/rcutorture/bin/kvm.sh b/tools/testing/selftests/rcutorture/bin/kvm.sh
index 42e5e8597a1a6e..ab341713edef83 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm.sh
@@ -252,9 +252,9 @@ do
shift
;;
--torture)
- checkarg --torture "(suite name)" "$#" "$2" '^\(lock\|rcu\|rcuscale\|refscale\|scf\|X.*\)$' '^--'
+ checkarg --torture "(suite name)" "$#" "$2" '^\(shazptr\|lock\|rcu\|rcuscale\|refscale\|scf\|X.*\)$' '^--'
TORTURE_SUITE=$2
- TORTURE_MOD="`echo $TORTURE_SUITE | sed -e 's/^\(lock\|rcu\|scf\)$/\1torture/'`"
+ TORTURE_MOD="`echo $TORTURE_SUITE | sed -e 's/^\(shazptr\|lock\|rcu\|scf\)$/\1torture/'`"
shift
if test "$TORTURE_SUITE" = rcuscale || test "$TORTURE_SUITE" = refscale
then