Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Documentation/litmus-tests: Make cmpxchg() tests safe for klitmus

The four litmus tests in Documentation/litmus-tests/atomic do not
declare all of their local variables. Although this is just fine for LKMM
analysis by herd7, it causes build failures when run in-kernel by klitmus.
This commit therefore adjusts these tests to declare all local variables.

Reported-by: Andrea Parri <parri.andrea@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Acked-by: Andrea Parri <parri.andrea@gmail.com>

+6 -4
+1
Documentation/litmus-tests/atomic/cmpxchg-fail-ordered-1.litmus
··· 23 23 P1(int *x, int *y, int *z) 24 24 { 25 25 int r0; 26 + int r1; 26 27 27 28 WRITE_ONCE(*y, 1); 28 29 r1 = cmpxchg(z, 1, 0);
+2 -2
Documentation/litmus-tests/atomic/cmpxchg-fail-ordered-2.litmus
··· 11 11 12 12 P0(int *x, int *y) 13 13 { 14 - int r0; 15 14 int r1; 16 15 17 16 WRITE_ONCE(*x, 1); ··· 19 20 20 21 P1(int *x, int *y) 21 22 { 22 - int r0; 23 + int r1; 24 + int r2; 23 25 24 26 r1 = cmpxchg(y, 0, 1); 25 27 smp_mb__after_atomic();
+1
Documentation/litmus-tests/atomic/cmpxchg-fail-unordered-1.litmus
··· 23 23 P1(int *x, int *y, int *z) 24 24 { 25 25 int r0; 26 + int r1; 26 27 27 28 WRITE_ONCE(*y, 1); 28 29 r1 = cmpxchg(z, 1, 0);
+2 -2
Documentation/litmus-tests/atomic/cmpxchg-fail-unordered-2.litmus
··· 12 12 13 13 P0(int *x, int *y) 14 14 { 15 - int r0; 16 15 int r1; 17 16 18 17 WRITE_ONCE(*x, 1); ··· 20 21 21 22 P1(int *x, int *y) 22 23 { 23 - int r0; 24 + int r1; 25 + int r2; 24 26 25 27 r1 = cmpxchg(y, 0, 1); 26 28 r2 = READ_ONCE(*x);