[PATCH 17/28] Documentation/litmus-tests: Add hazptr drain resnapshot-slot-race test
From: Kunwu Chan
Date: Wed Nov 04 2026 - 12:11:17 EST
Model the marker consumption race between the resnapshot
recovery path and a reader release: only one path may consume
the drain_gen marker (the cmpxchg in the implementation). The
Sometimes result confirms the race window exists
(herd7: Sometimes).
Signed-off-by: Kunwu Chan <kunwu.chan@xxxxxxxxx>
---
Documentation/litmus-tests/README | 4 +++
.../hazptr-drain-resnapshot-slot-race.litmus | 36 +++++++++++++++++++
2 files changed, 40 insertions(+)
create mode 100644 Documentation/litmus-tests/hazptr/hazptr-drain-resnapshot-slot-race.litmus
diff --git a/Documentation/litmus-tests/README b/Documentation/litmus-tests/README
index daab126e45a2..02c26d6bea50 100644
--- a/Documentation/litmus-tests/README
+++ b/Documentation/litmus-tests/README
@@ -115,3 +115,7 @@ hazptr-drain-engage-wildcard.litmus
Test the drain engage's wildcard defer: an engage that reads a
slot holding a wildcard (an in-flight slow-path acquire) must
not complete for the target address.
+
+hazptr-drain-resnapshot-slot-race.litmus
+ Test the marker consumption race between the resnapshot recovery
+ path and a reader release: only one path may consume the marker.
diff --git a/Documentation/litmus-tests/hazptr/hazptr-drain-resnapshot-slot-race.litmus b/Documentation/litmus-tests/hazptr/hazptr-drain-resnapshot-slot-race.litmus
new file mode 100644
index 000000000000..699cbf0e3d7a
--- /dev/null
+++ b/Documentation/litmus-tests/hazptr/hazptr-drain-resnapshot-slot-race.litmus
@@ -0,0 +1,36 @@
+C hazptr-drain-resnapshot-slot-race
+
+(*
+ * Result: Sometimes
+ *
+ * Models the marker consumption race between the resnapshot
+ * recovery path (P0) and a reader release (P1). The shared
+ * slot_gen represents drain_gen; only one path may consume
+ * the marker (cmpxchg in the implementation).
+ *
+ * The Sometimes result confirms the race window exists; the
+ * cmpxchg ensures only one of the release hook, resnapshot,
+ * or unchain path decrements backup_outstanding.
+ *)
+
+{
+ slot_addr = 3;
+ slot_gen = 1;
+}
+
+P0(int *slot_addr, int *slot_gen)
+{
+ int r0;
+
+ r0 = READ_ONCE(*slot_addr);
+ if (r0 != 3)
+ WRITE_ONCE(*slot_gen, 0);
+}
+
+P1(int *slot_addr, int *slot_gen)
+{
+ WRITE_ONCE(*slot_addr, 0);
+ smp_store_release(slot_gen, 0);
+}
+
+exists (0:r0=3 /\ slot_gen=0)
--
2.43.0