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

tools/memory-model: Rename litmus tests to comply to norm7

norm7 produces the 'normalized' name of a litmus test, when the test
can be generated from a single cycle that passes through each process
exactly once. The commit renames such tests in order to comply to the
naming scheme implemented by this tool.

Signed-off-by: Andrea Parri <andrea.parri@amarulasolutions.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Cc: Akira Yokosawa <akiyks@gmail.com>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Jade Alglave <j.alglave@ucl.ac.uk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Luc Maranget <luc.maranget@inria.fr>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will.deacon@arm.com>
Cc: linux-arch@vger.kernel.org
Cc: parri.andrea@gmail.com
Link: http://lkml.kernel.org/r/20180716180605.16115-14-paulmck@linux.vnet.ibm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Andrea Parri and committed by
Ingo Molnar
71b7ff5e 0fcff171

+30 -30
+4 -4
tools/memory-model/Documentation/recipes.txt
··· 126 126 locking will be seen as ordered by CPUs not holding that lock. 127 127 Consider this example: 128 128 129 - /* See Z6.0+pooncelock+pooncelock+pombonce.litmus. */ 129 + /* See Z6.0+pooncerelease+poacquirerelease+fencembonceonce.litmus. */ 130 130 void CPU0(void) 131 131 { 132 132 spin_lock(&mylock); ··· 292 292 smp_wmb() and smp_rmb() APIs are still heavily used, so it is important 293 293 to understand their use cases. The general approach is shown below: 294 294 295 - /* See MP+wmbonceonce+rmbonceonce.litmus. */ 295 + /* See MP+fencewmbonceonce+fencermbonceonce.litmus. */ 296 296 void CPU0(void) 297 297 { 298 298 WRITE_ONCE(x, 1); ··· 360 360 One way of avoiding the counter-intuitive outcome is through the use of a 361 361 control dependency paired with a full memory barrier: 362 362 363 - /* See LB+ctrlonceonce+mbonceonce.litmus. */ 363 + /* See LB+fencembonceonce+ctrlonceonce.litmus. */ 364 364 void CPU0(void) 365 365 { 366 366 r0 = READ_ONCE(x); ··· 476 476 while another CPU stores to the second variable and then loads from the 477 477 first. Preserving order requires nothing less than full barriers: 478 478 479 - /* See SB+mbonceonces.litmus. */ 479 + /* See SB+fencembonceonces.litmus. */ 480 480 void CPU0(void) 481 481 { 482 482 WRITE_ONCE(x, 1);
+10 -10
tools/memory-model/README
··· 35 35 The memory model is used, in conjunction with "herd7", to exhaustively 36 36 explore the state space of small litmus tests. 37 37 38 - For example, to run SB+mbonceonces.litmus against the memory model: 38 + For example, to run SB+fencembonceonces.litmus against the memory model: 39 39 40 - $ herd7 -conf linux-kernel.cfg litmus-tests/SB+mbonceonces.litmus 40 + $ herd7 -conf linux-kernel.cfg litmus-tests/SB+fencembonceonces.litmus 41 41 42 42 Here is the corresponding output: 43 43 44 - Test SB+mbonceonces Allowed 44 + Test SB+fencembonceonces Allowed 45 45 States 3 46 46 0:r0=0; 1:r0=1; 47 47 0:r0=1; 1:r0=0; ··· 50 50 Witnesses 51 51 Positive: 0 Negative: 3 52 52 Condition exists (0:r0=0 /\ 1:r0=0) 53 - Observation SB+mbonceonces Never 0 3 54 - Time SB+mbonceonces 0.01 53 + Observation SB+fencembonceonces Never 0 3 54 + Time SB+fencembonceonces 0.01 55 55 Hash=d66d99523e2cac6b06e66f4c995ebb48 56 56 57 57 The "Positive: 0 Negative: 3" and the "Never 0 3" each indicate that ··· 67 67 The "klitmus7" tool converts a litmus test into a Linux kernel module, 68 68 which may then be loaded and run. 69 69 70 - For example, to run SB+mbonceonces.litmus against hardware: 70 + For example, to run SB+fencembonceonces.litmus against hardware: 71 71 72 72 $ mkdir mymodules 73 - $ klitmus7 -o mymodules litmus-tests/SB+mbonceonces.litmus 73 + $ klitmus7 -o mymodules litmus-tests/SB+fencembonceonces.litmus 74 74 $ cd mymodules ; make 75 75 $ sudo sh run.sh 76 76 77 77 The corresponding output includes: 78 78 79 - Test SB+mbonceonces Allowed 79 + Test SB+fencembonceonces Allowed 80 80 Histogram (3 states) 81 81 644580 :>0:r0=1; 1:r0=0; 82 82 644328 :>0:r0=0; 1:r0=1; ··· 86 86 Positive: 0, Negative: 2000000 87 87 Condition exists (0:r0=0 /\ 1:r0=0) is NOT validated 88 88 Hash=d66d99523e2cac6b06e66f4c995ebb48 89 - Observation SB+mbonceonces Never 0 2000000 90 - Time SB+mbonceonces 0.16 89 + Observation SB+fencembonceonces Never 0 2000000 90 + Time SB+fencembonceonces 0.16 91 91 92 92 The "Positive: 0 Negative: 2000000" and the "Never 0 2000000" indicate 93 93 that during two million trials, the state specified in this litmus
+1 -1
tools/memory-model/litmus-tests/IRIW+mbonceonces+OnceOnce.litmus tools/memory-model/litmus-tests/IRIW+fencembonceonces+OnceOnce.litmus
··· 1 - C IRIW+mbonceonces+OnceOnce 1 + C IRIW+fencembonceonces+OnceOnce 2 2 3 3 (* 4 4 * Result: Never
+1 -1
tools/memory-model/litmus-tests/LB+ctrlonceonce+mbonceonce.litmus tools/memory-model/litmus-tests/LB+fencembonceonce+ctrlonceonce.litmus
··· 1 - C LB+ctrlonceonce+mbonceonce 1 + C LB+fencembonceonce+ctrlonceonce 2 2 3 3 (* 4 4 * Result: Never
+1 -1
tools/memory-model/litmus-tests/MP+wmbonceonce+rmbonceonce.litmus tools/memory-model/litmus-tests/MP+fencewmbonceonce+fencermbonceonce.litmus
··· 1 - C MP+wmbonceonce+rmbonceonce 1 + C MP+fencewmbonceonce+fencermbonceonce 2 2 3 3 (* 4 4 * Result: Never
+1 -1
tools/memory-model/litmus-tests/R+mbonceonces.litmus tools/memory-model/litmus-tests/R+fencembonceonces.litmus
··· 1 - C R+mbonceonces 1 + C R+fencembonceonces 2 2 3 3 (* 4 4 * Result: Never
+8 -8
tools/memory-model/litmus-tests/README
··· 18 18 Test of write-write coherence, that is, whether or not two 19 19 successive writes to the same variable are ordered. 20 20 21 - IRIW+mbonceonces+OnceOnce.litmus 21 + IRIW+fencembonceonces+OnceOnce.litmus 22 22 Test of independent reads from independent writes with smp_mb() 23 23 between each pairs of reads. In other words, is smp_mb() 24 24 sufficient to cause two different reading processes to agree on ··· 47 47 Can a release-acquire chain order a prior store against 48 48 a later load? 49 49 50 - LB+ctrlonceonce+mbonceonce.litmus 50 + LB+fencembonceonce+ctrlonceonce.litmus 51 51 Does a control dependency and an smp_mb() suffice for the 52 52 load-buffering litmus test, where each process reads from one 53 53 of two variables then writes to the other? ··· 88 88 As below, but with the first access of the writer process 89 89 and the second access of reader process protected by a lock. 90 90 91 - MP+wmbonceonce+rmbonceonce.litmus 91 + MP+fencewmbonceonce+fencermbonceonce.litmus 92 92 Does a smp_wmb() (between the stores) and an smp_rmb() (between 93 93 the loads) suffice for the message-passing litmus test, where one 94 94 process writes data and then a flag, and the other process reads 95 95 the flag and then the data. (This is similar to the ISA2 tests, 96 96 but with two processes instead of three.) 97 97 98 - R+mbonceonces.litmus 98 + R+fencembonceonces.litmus 99 99 This is the fully ordered (via smp_mb()) version of one of 100 100 the classic counterintuitive litmus tests that illustrates the 101 101 effects of store propagation delays. ··· 103 103 R+poonceonces.litmus 104 104 As above, but without the smp_mb() invocations. 105 105 106 - SB+mbonceonces.litmus 106 + SB+fencembonceonces.litmus 107 107 This is the fully ordered (again, via smp_mb() version of store 108 108 buffering, which forms the core of Dekker's mutual-exclusion 109 109 algorithm. ··· 123 123 S+poonceonces.litmus 124 124 As below, but without the smp_wmb() and acquire load. 125 125 126 - S+wmbonceonce+poacquireonce.litmus 126 + S+fencewmbonceonce+poacquireonce.litmus 127 127 Can a smp_wmb(), instead of a release, and an acquire order 128 128 a prior store against a subsequent store? 129 129 130 130 WRC+poonceonces+Once.litmus 131 - WRC+pooncerelease+rmbonceonce+Once.litmus 131 + WRC+pooncerelease+fencermbonceonce+Once.litmus 132 132 These two are members of an extension of the MP litmus-test 133 133 class in which the first write is moved to a separate process. 134 134 The second is forbidden because smp_store_release() is ··· 143 143 As above, but with smp_mb__after_spinlock() immediately 144 144 following the spin_lock(). 145 145 146 - Z6.0+pooncerelease+poacquirerelease+mbonceonce.litmus 146 + Z6.0+pooncerelease+poacquirerelease+fencembonceonce.litmus 147 147 Is the ordering provided by a release-acquire chain sufficient 148 148 to make ordering apparent to accesses by a process that does 149 149 not participate in that release-acquire chain?
+1 -1
tools/memory-model/litmus-tests/S+wmbonceonce+poacquireonce.litmus tools/memory-model/litmus-tests/S+fencewmbonceonce+poacquireonce.litmus
··· 1 - C S+wmbonceonce+poacquireonce 1 + C S+fencewmbonceonce+poacquireonce 2 2 3 3 (* 4 4 * Result: Never
+1 -1
tools/memory-model/litmus-tests/SB+mbonceonces.litmus tools/memory-model/litmus-tests/SB+fencembonceonces.litmus
··· 1 - C SB+mbonceonces 1 + C SB+fencembonceonces 2 2 3 3 (* 4 4 * Result: Never
+1 -1
tools/memory-model/litmus-tests/WRC+pooncerelease+rmbonceonce+Once.litmus tools/memory-model/litmus-tests/WRC+pooncerelease+fencermbonceonce+Once.litmus
··· 1 - C WRC+pooncerelease+rmbonceonce+Once 1 + C WRC+pooncerelease+fencermbonceonce+Once 2 2 3 3 (* 4 4 * Result: Never
+1 -1
tools/memory-model/litmus-tests/Z6.0+pooncerelease+poacquirerelease+mbonceonce.litmus tools/memory-model/litmus-tests/Z6.0+pooncerelease+poacquirerelease+fencembonceonce.litmus
··· 1 - C Z6.0+pooncerelease+poacquirerelease+mbonceonce 1 + C Z6.0+pooncerelease+poacquirerelease+fencembonceonce 2 2 3 3 (* 4 4 * Result: Sometimes