Skip to content

Commit

Permalink
Documentation/litmus-tests: Make cmpxchg() tests safe for klitmus
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Paul E. McKenney committed May 6, 2024
1 parent d372e20 commit 2ba5b41
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ P0(int *x, int *y, int *z)
P1(int *x, int *y, int *z)
{
int r0;
int r1;

WRITE_ONCE(*y, 1);
r1 = cmpxchg(z, 1, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ C cmpxchg-fail-ordered-2

P0(int *x, int *y)
{
int r0;
int r1;

WRITE_ONCE(*x, 1);
Expand All @@ -20,7 +19,8 @@ P0(int *x, int *y)

P1(int *x, int *y)
{
int r0;
int r1;
int r2;

r1 = cmpxchg(y, 0, 1);
smp_mb__after_atomic();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ P0(int *x, int *y, int *z)
P1(int *x, int *y, int *z)
{
int r0;
int r1;

WRITE_ONCE(*y, 1);
r1 = cmpxchg(z, 1, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ C cmpxchg-fail-unordered-2

P0(int *x, int *y)
{
int r0;
int r1;

WRITE_ONCE(*x, 1);
Expand All @@ -21,7 +20,8 @@ P0(int *x, int *y)

P1(int *x, int *y)
{
int r0;
int r1;
int r2;

r1 = cmpxchg(y, 0, 1);
r2 = READ_ONCE(*x);
Expand Down

0 comments on commit 2ba5b41

Please sign in to comment.