forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge tag 'lkmm.2022.01.09a' of git://git.kernel.org/pub/scm/linux/ke…
…rnel/git/paulmck/linux-rcu Pull memory model documentation updates from Paul McKenney: "This series contains documentation and litmus tests for locking, courtesy of Boqun Feng" * tag 'lkmm.2022.01.09a' of git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu: tools/memory-model: litmus: Add two tests for unlock(A)+lock(B) ordering tools/memory-model: doc: Describe the requirement of the litmus-tests directory tools/memory-model: Provide extra ordering for unlock+lock pair on the same CPU
- Loading branch information
Showing
6 changed files
with
116 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
tools/memory-model/litmus-tests/LB+unlocklockonceonce+poacquireonce.litmus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
C LB+unlocklockonceonce+poacquireonce | ||
|
||
(* | ||
* Result: Never | ||
* | ||
* If two locked critical sections execute on the same CPU, all accesses | ||
* in the first must execute before any accesses in the second, even if the | ||
* critical sections are protected by different locks. Note: Even when a | ||
* write executes before a read, their memory effects can be reordered from | ||
* the viewpoint of another CPU (the kind of reordering allowed by TSO). | ||
*) | ||
|
||
{} | ||
|
||
P0(spinlock_t *s, spinlock_t *t, int *x, int *y) | ||
{ | ||
int r1; | ||
|
||
spin_lock(s); | ||
r1 = READ_ONCE(*x); | ||
spin_unlock(s); | ||
spin_lock(t); | ||
WRITE_ONCE(*y, 1); | ||
spin_unlock(t); | ||
} | ||
|
||
P1(int *x, int *y) | ||
{ | ||
int r2; | ||
|
||
r2 = smp_load_acquire(y); | ||
WRITE_ONCE(*x, 1); | ||
} | ||
|
||
exists (0:r1=1 /\ 1:r2=1) |
33 changes: 33 additions & 0 deletions
33
tools/memory-model/litmus-tests/MP+unlocklockonceonce+fencermbonceonce.litmus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
C MP+unlocklockonceonce+fencermbonceonce | ||
|
||
(* | ||
* Result: Never | ||
* | ||
* If two locked critical sections execute on the same CPU, stores in the | ||
* first must propagate to each CPU before stores in the second do, even if | ||
* the critical sections are protected by different locks. | ||
*) | ||
|
||
{} | ||
|
||
P0(spinlock_t *s, spinlock_t *t, int *x, int *y) | ||
{ | ||
spin_lock(s); | ||
WRITE_ONCE(*x, 1); | ||
spin_unlock(s); | ||
spin_lock(t); | ||
WRITE_ONCE(*y, 1); | ||
spin_unlock(t); | ||
} | ||
|
||
P1(int *x, int *y) | ||
{ | ||
int r1; | ||
int r2; | ||
|
||
r1 = READ_ONCE(*y); | ||
smp_rmb(); | ||
r2 = READ_ONCE(*x); | ||
} | ||
|
||
exists (1:r1=1 /\ 1:r2=0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters