README 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. ============
  2. LITMUS TESTS
  3. ============
  4. CoRR+poonceonce+Once.litmus
  5. Test of read-read coherence, that is, whether or not two
  6. successive reads from the same variable are ordered.
  7. CoRW+poonceonce+Once.litmus
  8. Test of read-write coherence, that is, whether or not a read
  9. from a given variable followed by a write to that same variable
  10. are ordered.
  11. CoWR+poonceonce+Once.litmus
  12. Test of write-read coherence, that is, whether or not a write
  13. to a given variable followed by a read from that same variable
  14. are ordered.
  15. CoWW+poonceonce.litmus
  16. Test of write-write coherence, that is, whether or not two
  17. successive writes to the same variable are ordered.
  18. IRIW+fencembonceonces+OnceOnce.litmus
  19. Test of independent reads from independent writes with smp_mb()
  20. between each pairs of reads. In other words, is smp_mb()
  21. sufficient to cause two different reading processes to agree on
  22. the order of a pair of writes, where each write is to a different
  23. variable by a different process? This litmus test is forbidden
  24. by LKMM's propagation rule.
  25. IRIW+poonceonces+OnceOnce.litmus
  26. Test of independent reads from independent writes with nothing
  27. between each pairs of reads. In other words, is anything at all
  28. needed to cause two different reading processes to agree on the
  29. order of a pair of writes, where each write is to a different
  30. variable by a different process?
  31. ISA2+pooncelock+pooncelock+pombonce.litmus
  32. Tests whether the ordering provided by a lock-protected S
  33. litmus test is visible to an external process whose accesses are
  34. separated by smp_mb(). This addition of an external process to
  35. S is otherwise known as ISA2.
  36. ISA2+poonceonces.litmus
  37. As below, but with store-release replaced with WRITE_ONCE()
  38. and load-acquire replaced with READ_ONCE().
  39. ISA2+pooncerelease+poacquirerelease+poacquireonce.litmus
  40. Can a release-acquire chain order a prior store against
  41. a later load?
  42. LB+fencembonceonce+ctrlonceonce.litmus
  43. Does a control dependency and an smp_mb() suffice for the
  44. load-buffering litmus test, where each process reads from one
  45. of two variables then writes to the other?
  46. LB+poacquireonce+pooncerelease.litmus
  47. Does a release-acquire pair suffice for the load-buffering
  48. litmus test, where each process reads from one of two variables then
  49. writes to the other?
  50. LB+poonceonces.litmus
  51. As above, but with store-release replaced with WRITE_ONCE()
  52. and load-acquire replaced with READ_ONCE().
  53. MP+onceassign+derefonce.litmus
  54. As below, but with rcu_assign_pointer() and an rcu_dereference().
  55. MP+polockmbonce+poacquiresilsil.litmus
  56. Protect the access with a lock and an smp_mb__after_spinlock()
  57. in one process, and use an acquire load followed by a pair of
  58. spin_is_locked() calls in the other process.
  59. MP+polockonce+poacquiresilsil.litmus
  60. Protect the access with a lock in one process, and use an
  61. acquire load followed by a pair of spin_is_locked() calls
  62. in the other process.
  63. MP+polocks.litmus
  64. As below, but with the second access of the writer process
  65. and the first access of reader process protected by a lock.
  66. MP+poonceonces.litmus
  67. As below, but without the smp_rmb() and smp_wmb().
  68. MP+pooncerelease+poacquireonce.litmus
  69. As below, but with a release-acquire chain.
  70. MP+porevlocks.litmus
  71. As below, but with the first access of the writer process
  72. and the second access of reader process protected by a lock.
  73. MP+fencewmbonceonce+fencermbonceonce.litmus
  74. Does a smp_wmb() (between the stores) and an smp_rmb() (between
  75. the loads) suffice for the message-passing litmus test, where one
  76. process writes data and then a flag, and the other process reads
  77. the flag and then the data. (This is similar to the ISA2 tests,
  78. but with two processes instead of three.)
  79. R+fencembonceonces.litmus
  80. This is the fully ordered (via smp_mb()) version of one of
  81. the classic counterintuitive litmus tests that illustrates the
  82. effects of store propagation delays.
  83. R+poonceonces.litmus
  84. As above, but without the smp_mb() invocations.
  85. SB+fencembonceonces.litmus
  86. This is the fully ordered (again, via smp_mb() version of store
  87. buffering, which forms the core of Dekker's mutual-exclusion
  88. algorithm.
  89. SB+poonceonces.litmus
  90. As above, but without the smp_mb() invocations.
  91. SB+rfionceonce-poonceonces.litmus
  92. This litmus test demonstrates that LKMM is not fully multicopy
  93. atomic. (Neither is it other multicopy atomic.) This litmus test
  94. also demonstrates the "locations" debugging aid, which designates
  95. additional registers and locations to be printed out in the dump
  96. of final states in the herd7 output. Without the "locations"
  97. statement, only those registers and locations mentioned in the
  98. "exists" clause will be printed.
  99. S+poonceonces.litmus
  100. As below, but without the smp_wmb() and acquire load.
  101. S+fencewmbonceonce+poacquireonce.litmus
  102. Can a smp_wmb(), instead of a release, and an acquire order
  103. a prior store against a subsequent store?
  104. WRC+poonceonces+Once.litmus
  105. WRC+pooncerelease+fencermbonceonce+Once.litmus
  106. These two are members of an extension of the MP litmus-test
  107. class in which the first write is moved to a separate process.
  108. The second is forbidden because smp_store_release() is
  109. A-cumulative in LKMM.
  110. Z6.0+pooncelock+pooncelock+pombonce.litmus
  111. Is the ordering provided by a spin_unlock() and a subsequent
  112. spin_lock() sufficient to make ordering apparent to accesses
  113. by a process not holding the lock?
  114. Z6.0+pooncelock+poonceLock+pombonce.litmus
  115. As above, but with smp_mb__after_spinlock() immediately
  116. following the spin_lock().
  117. Z6.0+pooncerelease+poacquirerelease+fencembonceonce.litmus
  118. Is the ordering provided by a release-acquire chain sufficient
  119. to make ordering apparent to accesses by a process that does
  120. not participate in that release-acquire chain?
  121. A great many more litmus tests are available here:
  122. https://github.com/paulmckrcu/litmus
  123. ==================
  124. LITMUS TEST NAMING
  125. ==================
  126. Litmus tests are usually named based on their contents, which means that
  127. looking at the name tells you what the litmus test does. The naming
  128. scheme covers litmus tests having a single cycle that passes through
  129. each process exactly once, so litmus tests not fitting this description
  130. are named on an ad-hoc basis.
  131. The structure of a litmus-test name is the litmus-test class, a plus
  132. sign ("+"), and one string for each process, separated by plus signs.
  133. The end of the name is ".litmus".
  134. The litmus-test classes may be found in the infamous test6.pdf:
  135. https://www.cl.cam.ac.uk/~pes20/ppc-supplemental/test6.pdf
  136. Each class defines the pattern of accesses and of the variables accessed.
  137. For example, if the one process writes to a pair of variables, and
  138. the other process reads from these same variables, the corresponding
  139. litmus-test class is "MP" (message passing), which may be found on the
  140. left-hand end of the second row of tests on page one of test6.pdf.
  141. The strings used to identify the actions carried out by each process are
  142. complex due to a desire to have short(er) names. Thus, there is a tool to
  143. generate these strings from a given litmus test's actions. For example,
  144. consider the processes from SB+rfionceonce-poonceonces.litmus:
  145. P0(int *x, int *y)
  146. {
  147. int r1;
  148. int r2;
  149. WRITE_ONCE(*x, 1);
  150. r1 = READ_ONCE(*x);
  151. r2 = READ_ONCE(*y);
  152. }
  153. P1(int *x, int *y)
  154. {
  155. int r3;
  156. int r4;
  157. WRITE_ONCE(*y, 1);
  158. r3 = READ_ONCE(*y);
  159. r4 = READ_ONCE(*x);
  160. }
  161. The next step is to construct a space-separated list of descriptors,
  162. interleaving descriptions of the relation between a pair of consecutive
  163. accesses with descriptions of the second access in the pair.
  164. P0()'s WRITE_ONCE() is read by its first READ_ONCE(), which is a
  165. reads-from link (rf) and internal to the P0() process. This is
  166. "rfi", which is an abbreviation for "reads-from internal". Because
  167. some of the tools string these abbreviations together with space
  168. characters separating processes, the first character is capitalized,
  169. resulting in "Rfi".
  170. P0()'s second access is a READ_ONCE(), as opposed to (for example)
  171. smp_load_acquire(), so next is "Once". Thus far, we have "Rfi Once".
  172. P0()'s third access is also a READ_ONCE(), but to y rather than x.
  173. This is related to P0()'s second access by program order ("po"),
  174. to a different variable ("d"), and both accesses are reads ("RR").
  175. The resulting descriptor is "PodRR". Because P0()'s third access is
  176. READ_ONCE(), we add another "Once" descriptor.
  177. A from-read ("fre") relation links P0()'s third to P1()'s first
  178. access, and the resulting descriptor is "Fre". P1()'s first access is
  179. WRITE_ONCE(), which as before gives the descriptor "Once". The string
  180. thus far is thus "Rfi Once PodRR Once Fre Once".
  181. The remainder of P1() is similar to P0(), which means we add
  182. "Rfi Once PodRR Once". Another fre links P1()'s last access to
  183. P0()'s first access, which is WRITE_ONCE(), so we add "Fre Once".
  184. The full string is thus:
  185. Rfi Once PodRR Once Fre Once Rfi Once PodRR Once Fre Once
  186. This string can be given to the "norm7" and "classify7" tools to
  187. produce the name:
  188. $ norm7 -bell linux-kernel.bell \
  189. Rfi Once PodRR Once Fre Once Rfi Once PodRR Once Fre Once | \
  190. sed -e 's/:.*//g'
  191. SB+rfionceonce-poonceonces
  192. Adding the ".litmus" suffix: SB+rfionceonce-poonceonces.litmus
  193. The descriptors that describe connections between consecutive accesses
  194. within the cycle through a given litmus test can be provided by the herd
  195. tool (Rfi, Po, Fre, and so on) or by the linux-kernel.bell file (Once,
  196. Release, Acquire, and so on).
  197. To see the full list of descriptors, execute the following command:
  198. $ diyone7 -bell linux-kernel.bell -show edges