WIP: shazptr: Add torture test for shazptr

Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
diff --git a/kernel/locking/Makefile b/kernel/locking/Makefile
index 1517076..8ab7167 100644
--- a/kernel/locking/Makefile
+++ b/kernel/locking/Makefile
@@ -31,5 +31,6 @@
 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 0000000..380823e
--- /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 9fe4d8d..33236bd 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -1607,6 +1607,21 @@
 	  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 42e5e85..ab34171 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm.sh
@@ -252,9 +252,9 @@
 		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