Skip to contentSkip to conversation

CodeSamples/formal/herd: Tweaks for new litmus tests

PATCH Applied Akira Yokosawa 2 participants 7 messages Nov 24, 2025 – Nov 27, 2025

lore
Share & tools
lore
#0 lore raw

cover CodeSamples/formal/herd: Tweaks for new litmus tests

Hi Paul,

I see a couple of minor issues in running

- make cross-klitmus; cd klitmus; make
- make run-herd7

under CodeSamples/formal/herd/.

This patch set should resolve those issues.

Thanks, Akira
--
Akira Yokosawa (3):
CodeSamples/.../herd: Declare non-int reg variables in init block CodeSamples/.../herd/Makefile: Add klitmus7-ready tests CodeSamples/formal/herd/Makefile: Exclude time-consuming test from
run-herd7

 ...-rcusync-o+o-o-rcusync-o+rl-o-o-rul.litmus |  3 +++
 ...usync-o+o-xchg-rcusync-o+rl-o-o-rul.litmus |  3 +++
 .../formal/herd/C-double-check-cas-2.litmus   |  2 ++
 .../formal/herd/C-double-check-rcu-2.litmus   |  2 ++
 .../formal/herd/C-double-check-rcu-3.litmus   |  3 +++
 .../formal/herd/C-double-check-rcu-4.litmus   |  4 ++++
 CodeSamples/formal/herd/Makefile              | 21 +++++++++++++++----
 7 files changed, 34 insertions(+), 4 deletions(-)

base-commit: 11bc82274338c587732236210f9f6aaa5b5c0343

Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/3 CodeSamples/.../herd: Declare non-int reg variables in init block

There are missing declarations of local variables listed in the "locations" or "exists" clause.

They can cause warnings from gcc that look like:

.../litmus0xx.c: In function 'code0':
.../litmus0xx.c:458:15: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
458 | *out_0_r1 = (int)r1;
| ^

Declare such local variables in the init blocks.

---
 .../herd/C-MP+o-o-rcusync-o+o-o-rcusync-o+rl-o-o-rul.litmus   | 3 +++
 .../C-MP+o-xchg-rcusync-o+o-xchg-rcusync-o+rl-o-o-rul.litmus  | 3 +++
 CodeSamples/formal/herd/C-double-check-cas-2.litmus           | 2 ++
 CodeSamples/formal/herd/C-double-check-rcu-2.litmus           | 2 ++
 CodeSamples/formal/herd/C-double-check-rcu-3.litmus           | 3 +++
 CodeSamples/formal/herd/C-double-check-rcu-4.litmus           | 4 ++++
 6 files changed, 17 insertions(+)
CodeSamples/formal/herd/C-MP+o-o-rcusync-o+o-o-rcusync-o+rl-o-o-rul.litmus +3 -0
index d074d6c1..58887051 100644
@@ -6,6 +6,9 @@ C C-MP+o-o-rcusync-o+o-o-rcusync-o+rl-o-o-rul
 	int b;
 	int c;
 	int *p=a;
+	int *0:r1;			(* \fcvexclude *)
+	int *1:r1;			(* \fcvexclude *)
+	int *2:r1;			(* \fcvexclude *)
 }
 
 P0(int *a, int *b, int *c, int **p)
CodeSamples/formal/herd/C-MP+o-xchg-rcusync-o+o-xchg-rcusync-o+rl-o-o-rul.litmus +3 -0
index 86ea5553..37c7cb0f 100644
@@ -6,6 +6,9 @@ C C-MP+o-xchg-rcusync-o+o-xchg-rcusync-o+rl-o-o-rul
 	int b;
 	int c;
 	int *p=a;			(* \lnlbl[init:p] *)
+	int *0:r1;			(* \fcvexclude *)
+	int *1:r1;			(* \fcvexclude *)
+	int *2:r1;			(* \fcvexclude *)
 }
 
 P0(int *a, int *b, int *c, int **p)
CodeSamples/formal/herd/C-double-check-cas-2.litmus +2 -0
index 4c2dc523..2296fe3d 100644
@@ -5,6 +5,8 @@ C C-double-check-cas-2
 	int a;
 	int b;
 	int *p=0;
+	int *0:r1;			(* \fcvexclude *)
+	int *1:r1;			(* \fcvexclude *)
 }
 
 P0(int *a, int *b, int **p)
CodeSamples/formal/herd/C-double-check-rcu-2.litmus +2 -0
index ff7a1dd3..a108d318 100644
@@ -5,6 +5,8 @@ C C-double-check-rcu-2
 	int a;
 	int b;
 	int *p=0;
+	int *0:r1;			(* \fcvexclude *)
+	int *1:r1;			(* \fcvexclude *)
 }
 
 P0(int *a, int *b, int **p)
CodeSamples/formal/herd/C-double-check-rcu-3.litmus +3 -0
index c5d5f9e4..6bff1f82 100644
@@ -6,6 +6,9 @@ C C-double-check-rcu-3
 	int b;
 	int c;
 	int *p=0;
+	int *0:r1;			(* \fcvexclude *)
+	int *1:r1;			(* \fcvexclude *)
+	int *2:r1;			(* \fcvexclude *)
 }
 
 P0(int *a, int *b, int *c, int **p)
CodeSamples/formal/herd/C-double-check-rcu-4.litmus +4 -0
index 02f34366..e81d5850 100644
@@ -7,6 +7,10 @@ C C-double-check-rcu-4
 	int c;
 	int d;
 	int *p=0;
+	int *0:r1;			(* \fcvexclude *)
+	int *1:r1;			(* \fcvexclude *)
+	int *2:r1;			(* \fcvexclude *)
+	int *3:r1;			(* \fcvexclude *)
 }
 
 P0(int *a, int *b, int *c, int *d, int **p)
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/3 CodeSamples/.../herd/Makefile: Add klitmus7-ready tests

In reply to Akira Yokosawa

While here, fold the long list as well.

---
 CodeSamples/formal/herd/Makefile | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
CodeSamples/formal/herd/Makefile +9 -1
index 069f77ea..257ee556 100644
@@ -49,7 +49,15 @@ ABSPERF_SHORT  := $(filter-out $(ABSPERF_LONG),$(ABSPERF_TEST))
 ABSPERF_OUT    = absperf.out absperf-all.out
 HERD7_TEST     := $(filter-out $(ABSPERF_TEST),$(HERD7_LITMUS))
 HERD7_OUT      := $(HERD7_TEST:%.litmus=%.out)
-KLITMUS_READY = C-Lock1 C-Lock2 C-RCU-remove C-RomanPenyaev-list-rcu-rr C-SB+o-rcusync-o+rl-o-o-rul
+KLITMUS_READY = \
+    C-Lock1 C-Lock2 \
+    C-RCU-remove C-RomanPenyaev-list-rcu-rr \
+    C-SB+o-rcusync-o+rl-o-o-rul \
+    C-MP+o-xchg-rcusync-o+o-xchg-rcusync-o+rl-o-o-rul \
+    C-MP+o-o-rcusync-o+o-o-rcusync-o+rl-o-o-rul \
+    C-double-check-cas-2 \
+    C-double-check-rcu-2 C-double-check-rcu-3 C-double-check-rcu-4
+
 KLITMUS_TEST   := $(addsuffix .litmus,$(KLITMUS_READY))
 
 .PHONY: all clean litmus2herd run-herd7 run-absperf run-absperf-all cross-klitmus
Signature · 1 line
2.43.0
#3 lore raw

PATCH 3/3 CodeSamples/formal/herd/Makefile: Exclude time-consuming test from run-herd7

In reply to Akira Yokosawa

C-double-check-rcu-4 needs 20 mins or so to complete. The other tests in "make run-herd7" take a few seconds at most. Exclude it from run-herd7 and let it be run by a new target:
run-dblcheck4.

---
 CodeSamples/formal/herd/Makefile | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
CodeSamples/formal/herd/Makefile +8 -3
index 257ee556..959b8ed7 100644
@@ -7,6 +7,7 @@
 # cross-klitmus7:  Cross-compile transformed litmus tests by klitmus7
 # run-absperf:     Run memory model benchmark tests of absperf
 # run-absperf-all: Run all absperf tests (including those take quite a while)
+# run-dblcheck4:   Run C-double-check-rcu-4 (takes 20 mins or so)
 #
 # Warning: absperf tests take more than 1 hour by default.
 #
@@ -47,7 +48,9 @@ ABSPERF_TEST   := $(wildcard C-SB+l-*.litmus)
 ABSPERF_LONG   := $(wildcard C-SB+l-o-o-u+l-o-o-u+l-o-o-u+l-o-o-u+l-o-o-u-*.litmus)
 ABSPERF_SHORT  := $(filter-out $(ABSPERF_LONG),$(ABSPERF_TEST))
 ABSPERF_OUT    = absperf.out absperf-all.out
-HERD7_TEST     := $(filter-out $(ABSPERF_TEST),$(HERD7_LITMUS))
+DBL_CHECK_LONG = C-double-check-rcu-4.litmus
+DBL_CHECK_LONG_OUT := $(DBL_CHECK_LONG:%.litmus=%.out)
+HERD7_TEST     := $(filter-out $(ABSPERF_TEST) $(DBL_CHECK_LONG),$(HERD7_LITMUS))
 HERD7_OUT      := $(HERD7_TEST:%.litmus=%.out)
 KLITMUS_READY = \
     C-Lock1 C-Lock2 \
@@ -61,7 +64,7 @@ KLITMUS_READY = \
 KLITMUS_TEST   := $(addsuffix .litmus,$(KLITMUS_READY))
 
 .PHONY: all clean litmus2herd run-herd7 run-absperf run-absperf-all cross-klitmus
-.PHONY: help
+.PHONY: run-dblcheck4 help
 
 all: litmus2herd
 
@@ -73,6 +76,7 @@ $(LITMUS7_HERD_TEST): %.herd: ../litmus/%
 run-herd7: $(LITMUS7_HERD_OUT) $(HERD7_OUT)
 run-absperf: absperf.out
 run-absperf-all: absperf-all.out
+run-dblcheck4: $(DBL_CHECK_LONG_OUT)
 
 $(LKMM_LIST):
 	@echo "#####################################################"
@@ -89,7 +93,7 @@ $(LITMUS7_HERD_OUT) $(ABSPERF_OUT) $(HERD7_OUT): $(LKMM_LIST)
 $(LITMUS7_HERD_OUT): %.out: %.herd
 	cd $(LKMM_DIR); herd7 -conf linux-kernel.cfg $(HERD_DIR)/$< > $(HERD_DIR)/$@
 
-$(HERD7_OUT): %.out: %.litmus
+$(HERD7_OUT) $(DBL_CHECK_LONG_OUT): %.out: %.litmus
 	cd $(LKMM_DIR); herd7 -conf linux-kernel.cfg $(HERD_DIR)/$< > $(HERD_DIR)/$@
 
 absperf.out: ABSPERF_LIST = $(ABSPERF_SHORT)
@@ -122,6 +126,7 @@ help:
 	@echo "    cross-klitmus7:  Cross-compile transformed litmus tests by klitmus7"
 	@echo "    run-absperf:     Run memory model benchmark tests of absperf"
 	@echo "    run-absperf-all: Run all absperf tests (including those take quite a while)"
+	@echo "    run-dblcheck4:   Run C-double-check-rcu-4 (takes 20 mins or so)"
 	@echo
 	@echo "Warning: absperf tests require more than 1 hour by default."
 	@echo "    Refer to comment in Makefile for instructions to override default setting."
Signature · 1 line
2.43.0
#4 lore raw
In reply to Akira Yokosawa
Quoted 10 lines · Akira Yokosawa

Hi Paul,

I see a couple of minor issues in running

- make cross-klitmus; cd klitmus; make
- make run-herd7

under CodeSamples/formal/herd/.

This patch set should resolve those issues.

Queued and pushed, thank you!

Thanx, Paul

Quoted 22 lines

Thanks, Akira
--
Akira Yokosawa (3):
CodeSamples/.../herd: Declare non-int reg variables in init block CodeSamples/.../herd/Makefile: Add klitmus7-ready tests CodeSamples/formal/herd/Makefile: Exclude time-consuming test from
run-herd7

 ...-rcusync-o+o-o-rcusync-o+rl-o-o-rul.litmus |  3 +++
 ...usync-o+o-xchg-rcusync-o+rl-o-o-rul.litmus |  3 +++
 .../formal/herd/C-double-check-cas-2.litmus   |  2 ++
 .../formal/herd/C-double-check-rcu-2.litmus   |  2 ++
 .../formal/herd/C-double-check-rcu-3.litmus   |  3 +++
 .../formal/herd/C-double-check-rcu-4.litmus   |  4 ++++
 CodeSamples/formal/herd/Makefile              | 21 +++++++++++++++----
 7 files changed, 34 insertions(+), 4 deletions(-)

base-commit: 11bc82274338c587732236210f9f6aaa5b5c0343

Signature · 1 line
2.43.0
#5 lore raw
Quoted 5 lines · Paul E. McKenney
Quoted 4 lines · Akira Yokosawa

Hi Paul,

I see a couple of minor issues in running

Quoted 8 lines
Quoted 6 lines

- make cross-klitmus; cd klitmus; make
- make run-herd7

under CodeSamples/formal/herd/.

This patch set should resolve those issues.

Queued and pushed, thank you!

Paul, this is a side note with regard to klitmus7.

In the old days with Linux kernel <6.0, tests listed in KLITMUS_READY took less than a minute.

That have changed a lot. Litmus tests with RCU primitives tend to take much longer.

In the list of processes shown by "top", such klitmus threads are accompanied by a single (and fairly busy) "rcu_exp_gp_kthread_worker". Yes, the frequency RCU primitives are invoked in those litmus tests, especially synchronize_rcu(), is unusually high. In realistic workloads, such burst of synchronize_rcu()s would indicate you are doing something wrong. So the longer time to complete does not mean any performance regression.

Following is a list of summaries from C-RomanPenyaev-list-rcu-rr runs under several VMs:

- Ubuntu 20.04 POWER8 (kernel: 5.4.0-223-generic #243-Ubuntu SMP, 8 CPUs)

Hash=890796f9231134fff935fc64b2b98940 Observation C-RomanPenyaev-list-rcu-rr Never 0 4000000 Time C-RomanPenyaev-list-rcu-rr 17.85

no rcu_exp_gp_kthread_worker.

- Ubuntu 24.04 POWER9 (kernel: 6.8.0-88-generic #89-Ubuntu SMP, 8 CPUs)

Hash=890796f9231134fff935fc64b2b98940 Observation C-RomanPenyaev-list-rcu-rr Never 0 4000000 Time C-RomanPenyaev-list-rcu-rr 153.49

no rcu_exp_gp_kthread_worker observed.

- Ubuntu 24.04 x86_64 (kernel: 6.8.0-88-generic #89-Ubuntu SMP PREEMPT_DYNAMIC, 6 CPUs)

Hash=890796f9231134fff935fc64b2b98940 Observation C-RomanPenyaev-list-rcu-rr Never 0 3000000 Time C-RomanPenyaev-list-rcu-rr 60.46

no rcu_exp_gp_kthread_worker.

- Ubuntu 25.10 x86_64 (kernel: 6.17.0-7-generic #7-Ubuntu SMP PREEMPT_DYNAMIC, 6 CPUs)

Hash=890796f9231134fff935fc64b2b98940 Observation C-RomanPenyaev-list-rcu-rr Never 0 3000000 Time C-RomanPenyaev-list-rcu-rr 311.79

rcu_exp_gp_kthread_worker consumes a lot of time.

- Fedora 43 x86_64 (kernel: 6.17.8-300.fc43.x86_64 #1 SMP PREEMPT_DYNAMIC, 6 CPUs)

Hash=890796f9231134fff935fc64b2b98940 Observation C-RomanPenyaev-list-rcu-rr Never 0 3000000 Time C-RomanPenyaev-list-rcu-rr 326.54

rcu_exp_gp_kthread_worker consumes a lot of time.

Just out of curiosity, is there any knob I can tweak to reduce the time to complete, preferably some kernel boot arg?

Thanks, Akira

#6 lore raw
Quoted 23 lines · Akira Yokosawa
Quoted 5 lines · Paul E. McKenney
Quoted 4 lines · Akira Yokosawa

Hi Paul,

I see a couple of minor issues in running

Quoted 8 lines
Quoted 6 lines

- make cross-klitmus; cd klitmus; make
- make run-herd7

under CodeSamples/formal/herd/.

This patch set should resolve those issues.

Queued and pushed, thank you!

Paul, this is a side note with regard to klitmus7.

In the old days with Linux kernel <6.0, tests listed in KLITMUS_READY took less than a minute.

That have changed a lot. Litmus tests with RCU primitives tend to take much longer.

Quoted 7 lines

In the list of processes shown by "top", such klitmus threads are accompanied by a single (and fairly busy) "rcu_exp_gp_kthread_worker". Yes, the frequency RCU primitives are invoked in those litmus tests, especially synchronize_rcu(), is unusually high. In realistic workloads, such burst of synchronize_rcu()s would indicate you are doing something wrong. So the longer time to complete does not mean any performance regression.

If I remember correctly, the klitmus tool switch from synchronize_rcu() to synchronize_rcu_expedited() at about that time. That would definitely account for the appearance of rcu_exp_gp_kthread_worker(), which handles expedited grace periods. The motivation for switching klitmus to synchronize_rcu_expedited() is that the shorter grace periods make detecting RCU-usage bugs in litmus tests.

Except that your data below shows that downgrading to a pre-v6.0 kernel reduces the overhead. Hmmm...

Quoted 35 lines

Following is a list of summaries from C-RomanPenyaev-list-rcu-rr runs under several VMs:

- Ubuntu 20.04 POWER8 (kernel: 5.4.0-223-generic #243-Ubuntu SMP, 8 CPUs)

Hash=890796f9231134fff935fc64b2b98940 Observation C-RomanPenyaev-list-rcu-rr Never 0 4000000 Time C-RomanPenyaev-list-rcu-rr 17.85

no rcu_exp_gp_kthread_worker.

- Ubuntu 24.04 POWER9 (kernel: 6.8.0-88-generic #89-Ubuntu SMP, 8 CPUs)

Hash=890796f9231134fff935fc64b2b98940 Observation C-RomanPenyaev-list-rcu-rr Never 0 4000000 Time C-RomanPenyaev-list-rcu-rr 153.49

no rcu_exp_gp_kthread_worker observed.

- Ubuntu 24.04 x86_64 (kernel: 6.8.0-88-generic #89-Ubuntu SMP PREEMPT_DYNAMIC, 6 CPUs)

Hash=890796f9231134fff935fc64b2b98940 Observation C-RomanPenyaev-list-rcu-rr Never 0 3000000 Time C-RomanPenyaev-list-rcu-rr 60.46

no rcu_exp_gp_kthread_worker.

- Ubuntu 25.10 x86_64 (kernel: 6.17.0-7-generic #7-Ubuntu SMP PREEMPT_DYNAMIC, 6 CPUs)

Hash=890796f9231134fff935fc64b2b98940 Observation C-RomanPenyaev-list-rcu-rr Never 0 3000000 Time C-RomanPenyaev-list-rcu-rr 311.79

rcu_exp_gp_kthread_worker consumes a lot of time.

Quoted 7 lines

- Fedora 43 x86_64 (kernel: 6.17.8-300.fc43.x86_64 #1 SMP PREEMPT_DYNAMIC, 6 CPUs)

Hash=890796f9231134fff935fc64b2b98940 Observation C-RomanPenyaev-list-rcu-rr Never 0 3000000 Time C-RomanPenyaev-list-rcu-rr 326.54

rcu_exp_gp_kthread_worker consumes a lot of time.

How much time? A full CPU's worth through the klitmus run? More than a CPU? Less?

You mention that this might not be a regression, but then again, it might well be. ;-)

Quoted 2 lines

Just out of curiosity, is there any knob I can tweak to reduce the time to complete, preferably some kernel boot arg?

Well, there is the rcupdate.rcu_normal=1 kernel boot parameter, which disables expedited grace periods completely. But that cure might be worse than the disease.

Just to make sure, you are using the exact same version of klitmus throughout, right?

If you are using the same klitmus throughout, are you comfortable building and booting kernels on any of these systems? (If so, I would ask you to bisect, but to focus only on changes affecting kernel/rcu, for example, "git bisect start v6.17 v6.8 -- kernel/rcu".)

Thanx, Paul