README 9.6 KB

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