xref: /linux/Documentation/litmus-tests/README (revision 293f5bc2)
1a591890cSJoel Fernandes (Google)============
2a591890cSJoel Fernandes (Google)LITMUS TESTS
3a591890cSJoel Fernandes (Google)============
4a591890cSJoel Fernandes (Google)
5cdaac9d6SAkira YokosawaEach subdirectory contains litmus tests that are typical to describe the
6cdaac9d6SAkira Yokosawasemantics of respective kernel APIs.
7cdaac9d6SAkira YokosawaFor more information about how to "run" a litmus test or how to generate
8cdaac9d6SAkira Yokosawaa kernel test module based on a litmus test, please see
9cdaac9d6SAkira Yokosawatools/memory-model/README.
10cdaac9d6SAkira Yokosawa
11cdaac9d6SAkira Yokosawa
1257373671SRandy Dunlapatomic (/atomic directory)
13cdaac9d6SAkira Yokosawa--------------------------
14cdaac9d6SAkira Yokosawa
15cdaac9d6SAkira YokosawaAtomic-RMW+mb__after_atomic-is-stronger-than-acquire.litmus
16cdaac9d6SAkira Yokosawa    Test that an atomic RMW followed by a smp_mb__after_atomic() is
17cdaac9d6SAkira Yokosawa    stronger than a normal acquire: both the read and write parts of
18cdaac9d6SAkira Yokosawa    the RMW are ordered before the subsequential memory accesses.
19cdaac9d6SAkira Yokosawa
20cdaac9d6SAkira YokosawaAtomic-RMW-ops-are-atomic-WRT-atomic_set.litmus
21cdaac9d6SAkira Yokosawa    Test that atomic_set() cannot break the atomicity of atomic RMWs.
225ef0a07aSAkira Yokosawa    NOTE: Require herd7 7.56 or later which supports "(void)expr".
23cdaac9d6SAkira Yokosawa
24*293f5bc2SPaul E. McKenneycmpxchg-fail-ordered-1.litmus
25*293f5bc2SPaul E. McKenney    Demonstrate that a failing cmpxchg() operation acts as a full barrier
26*293f5bc2SPaul E. McKenney    when followed by smp_mb__after_atomic().
27*293f5bc2SPaul E. McKenney
28*293f5bc2SPaul E. McKenneycmpxchg-fail-ordered-2.litmus
29*293f5bc2SPaul E. McKenney    Demonstrate that a failing cmpxchg() operation acts as an acquire
30*293f5bc2SPaul E. McKenney    operation when followed by smp_mb__after_atomic().
31*293f5bc2SPaul E. McKenney
32*293f5bc2SPaul E. McKenneycmpxchg-fail-unordered-1.litmus
33*293f5bc2SPaul E. McKenney    Demonstrate that a failing cmpxchg() operation does not act as a
34*293f5bc2SPaul E. McKenney    full barrier.
35*293f5bc2SPaul E. McKenney
36*293f5bc2SPaul E. McKenneycmpxchg-fail-unordered-2.litmus
37*293f5bc2SPaul E. McKenney    Demonstrate that a failing cmpxchg() operation does not act as an
38*293f5bc2SPaul E. McKenney    acquire operation.
39*293f5bc2SPaul E. McKenney
40cdaac9d6SAkira Yokosawa
41d2c470c4SPaul E. McKenneylocking (/locking directory)
42d2c470c4SPaul E. McKenney----------------------------
43d2c470c4SPaul E. McKenney
44d2c470c4SPaul E. McKenneyDCL-broken.litmus
45d2c470c4SPaul E. McKenney    Demonstrates that double-checked locking needs more than just
46d2c470c4SPaul E. McKenney    the obvious lock acquisitions and releases.
47d2c470c4SPaul E. McKenney
48d2c470c4SPaul E. McKenneyDCL-fixed.litmus
49d2c470c4SPaul E. McKenney    Demonstrates corrected double-checked locking that uses
50d2c470c4SPaul E. McKenney    smp_store_release() and smp_load_acquire() in addition to the
51d2c470c4SPaul E. McKenney    obvious lock acquisitions and releases.
52d2c470c4SPaul E. McKenney
53d2c470c4SPaul E. McKenneyRM-broken.litmus
54d2c470c4SPaul E. McKenney    Demonstrates problems with "roach motel" locking, where code is
55d2c470c4SPaul E. McKenney    freely moved into lock-based critical sections.  This example also
56d2c470c4SPaul E. McKenney    shows how to use the "filter" clause to discard executions that
57d2c470c4SPaul E. McKenney    would be excluded by other code not modeled in the litmus test.
58d2c470c4SPaul E. McKenney    Note also that this "roach motel" optimization is emulated by
59d2c470c4SPaul E. McKenney    physically moving P1()'s two reads from x under the lock.
60d2c470c4SPaul E. McKenney
61d2c470c4SPaul E. McKenney    What is a roach motel?  This is from an old advertisement for
62d2c470c4SPaul E. McKenney    a cockroach trap, much later featured in one of the "Men in
63d2c470c4SPaul E. McKenney    Black" movies.  "The roaches check in.  They don't check out."
64d2c470c4SPaul E. McKenney
65d2c470c4SPaul E. McKenneyRM-fixed.litmus
66d2c470c4SPaul E. McKenney    The counterpart to RM-broken.litmus, showing P0()'s two loads from
67d2c470c4SPaul E. McKenney    x safely outside of the critical section.
68d2c470c4SPaul E. McKenney
69d2c470c4SPaul E. McKenney
70a591890cSJoel Fernandes (Google)RCU (/rcu directory)
71a591890cSJoel Fernandes (Google)--------------------
72a591890cSJoel Fernandes (Google)
73c425fb5fSJoel Fernandes (Google)MP+onceassign+derefonce.litmus (under tools/memory-model/litmus-tests/)
74c425fb5fSJoel Fernandes (Google)    Demonstrates the use of rcu_assign_pointer() and rcu_dereference() to
75c425fb5fSJoel Fernandes (Google)    ensure that an RCU reader will not see pre-initialization garbage.
76c425fb5fSJoel Fernandes (Google)
77a591890cSJoel Fernandes (Google)RCU+sync+read.litmus
78a591890cSJoel Fernandes (Google)RCU+sync+free.litmus
79a591890cSJoel Fernandes (Google)    Both the above litmus tests demonstrate the RCU grace period guarantee
80a591890cSJoel Fernandes (Google)    that an RCU read-side critical section can never span a grace period.
81