litmus-tests.txt 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108
  1. Linux-Kernel Memory Model Litmus Tests
  2. ======================================
  3. This file describes the LKMM litmus-test format by example, describes
  4. some tricks and traps, and finally outlines LKMM's limitations. Earlier
  5. versions of this material appeared in a number of LWN articles, including:
  6. https://lwn.net/Articles/720550/
  7. A formal kernel memory-ordering model (part 2)
  8. https://lwn.net/Articles/608550/
  9. Axiomatic validation of memory barriers and atomic instructions
  10. https://lwn.net/Articles/470681/
  11. Validating Memory Barriers and Atomic Instructions
  12. This document presents information in decreasing order of applicability,
  13. so that, where possible, the information that has proven more commonly
  14. useful is shown near the beginning.
  15. For information on installing LKMM, including the underlying "herd7"
  16. tool, please see tools/memory-model/README.
  17. Copy-Pasta
  18. ==========
  19. As with other software, it is often better (if less macho) to adapt an
  20. existing litmus test than it is to create one from scratch. A number
  21. of litmus tests may be found in the kernel source tree:
  22. tools/memory-model/litmus-tests/
  23. Documentation/litmus-tests/
  24. Several thousand more example litmus tests are available on github
  25. and kernel.org:
  26. https://github.com/paulmckrcu/litmus
  27. https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/perfbook.git/tree/CodeSamples/formal/herd
  28. https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/perfbook.git/tree/CodeSamples/formal/litmus
  29. The -l and -L arguments to "git grep" can be quite helpful in identifying
  30. existing litmus tests that are similar to the one you need. But even if
  31. you start with an existing litmus test, it is still helpful to have a
  32. good understanding of the litmus-test format.
  33. Examples and Format
  34. ===================
  35. This section describes the overall format of litmus tests, starting
  36. with a small example of the message-passing pattern and moving on to
  37. more complex examples that illustrate explicit initialization and LKMM's
  38. minimalistic set of flow-control statements.
  39. Message-Passing Example
  40. -----------------------
  41. This section gives an overview of the format of a litmus test using an
  42. example based on the common message-passing use case. This use case
  43. appears often in the Linux kernel. For example, a flag (modeled by "y"
  44. below) indicates that a buffer (modeled by "x" below) is now completely
  45. filled in and ready for use. It would be very bad if the consumer saw the
  46. flag set, but, due to memory misordering, saw old values in the buffer.
  47. This example asks whether smp_store_release() and smp_load_acquire()
  48. suffices to avoid this bad outcome:
  49. 1 C MP+pooncerelease+poacquireonce
  50. 2
  51. 3 {}
  52. 4
  53. 5 P0(int *x, int *y)
  54. 6 {
  55. 7 WRITE_ONCE(*x, 1);
  56. 8 smp_store_release(y, 1);
  57. 9 }
  58. 10
  59. 11 P1(int *x, int *y)
  60. 12 {
  61. 13 int r0;
  62. 14 int r1;
  63. 15
  64. 16 r0 = smp_load_acquire(y);
  65. 17 r1 = READ_ONCE(*x);
  66. 18 }
  67. 19
  68. 20 exists (1:r0=1 /\ 1:r1=0)
  69. Line 1 starts with "C", which identifies this file as being in the
  70. LKMM C-language format (which, as we will see, is a small fragment
  71. of the full C language). The remainder of line 1 is the name of
  72. the test, which by convention is the filename with the ".litmus"
  73. suffix stripped. In this case, the actual test may be found in
  74. tools/memory-model/litmus-tests/MP+pooncerelease+poacquireonce.litmus
  75. in the Linux-kernel source tree.
  76. Mechanically generated litmus tests will often have an optional
  77. double-quoted comment string on the second line. Such strings are ignored
  78. when running the test. Yes, you can add your own comments to litmus
  79. tests, but this is a bit involved due to the use of multiple parsers.
  80. For now, you can use C-language comments in the C code, and these comments
  81. may be in either the "/* */" or the "//" style. A later section will
  82. cover the full litmus-test commenting story.
  83. Line 3 is the initialization section. Because the default initialization
  84. to zero suffices for this test, the "{}" syntax is used, which mean the
  85. initialization section is empty. Litmus tests requiring non-default
  86. initialization must have non-empty initialization sections, as in the
  87. example that will be presented later in this document.
  88. Lines 5-9 show the first process and lines 11-18 the second process. Each
  89. process corresponds to a Linux-kernel task (or kthread, workqueue, thread,
  90. and so on; LKMM discussions often use these terms interchangeably).
  91. The name of the first process is "P0" and that of the second "P1".
  92. You can name your processes anything you like as long as the names consist
  93. of a single "P" followed by a number, and as long as the numbers are
  94. consecutive starting with zero. This can actually be quite helpful,
  95. for example, a .litmus file matching "^P1(" but not matching "^P2("
  96. must contain a two-process litmus test.
  97. The argument list for each function are pointers to the global variables
  98. used by that function. Unlike normal C-language function parameters, the
  99. names are significant. The fact that both P0() and P1() have a formal
  100. parameter named "x" means that these two processes are working with the
  101. same global variable, also named "x". So the "int *x, int *y" on P0()
  102. and P1() mean that both processes are working with two shared global
  103. variables, "x" and "y". Global variables are always passed to processes
  104. by reference, hence "P0(int *x, int *y)", but *never* "P0(int x, int y)".
  105. P0() has no local variables, but P1() has two of them named "r0" and "r1".
  106. These names may be freely chosen, but for historical reasons stemming from
  107. other litmus-test formats, it is conventional to use names consisting of
  108. "r" followed by a number as shown here. A common bug in litmus tests
  109. is forgetting to add a global variable to a process's parameter list.
  110. This will sometimes result in an error message, but can also cause the
  111. intended global to instead be silently treated as an undeclared local
  112. variable.
  113. Each process's code is similar to Linux-kernel C, as can be seen on lines
  114. 7-8 and 13-17. This code may use many of the Linux kernel's atomic
  115. operations, some of its exclusive-lock functions, and some of its RCU
  116. and SRCU functions. An approximate list of the currently supported
  117. functions may be found in the linux-kernel.def file.
  118. The P0() process does "WRITE_ONCE(*x, 1)" on line 7. Because "x" is a
  119. pointer in P0()'s parameter list, this does an unordered store to global
  120. variable "x". Line 8 does "smp_store_release(y, 1)", and because "y"
  121. is also in P0()'s parameter list, this does a release store to global
  122. variable "y".
  123. The P1() process declares two local variables on lines 13 and 14.
  124. Line 16 does "r0 = smp_load_acquire(y)" which does an acquire load
  125. from global variable "y" into local variable "r0". Line 17 does a
  126. "r1 = READ_ONCE(*x)", which does an unordered load from "*x" into local
  127. variable "r1". Both "x" and "y" are in P1()'s parameter list, so both
  128. reference the same global variables that are used by P0().
  129. Line 20 is the "exists" assertion expression to evaluate the final state.
  130. This final state is evaluated after the dust has settled: both processes
  131. have completed and all of their memory references and memory barriers
  132. have propagated to all parts of the system. The references to the local
  133. variables "r0" and "r1" in line 24 must be prefixed with "1:" to specify
  134. which process they are local to.
  135. Note that the assertion expression is written in the litmus-test
  136. language rather than in C. For example, single "=" is an equality
  137. operator rather than an assignment. The "/\" character combination means
  138. "and". Similarly, "\/" stands for "or". Both of these are ASCII-art
  139. representations of the corresponding mathematical symbols. Finally,
  140. "~" stands for "logical not", which is "!" in C, and not to be confused
  141. with the C-language "~" operator which instead stands for "bitwise not".
  142. Parentheses may be used to override precedence.
  143. The "exists" assertion on line 20 is satisfied if the consumer sees the
  144. flag ("y") set but the buffer ("x") as not yet filled in, that is, if P1()
  145. loaded a value from "x" that was equal to 1 but loaded a value from "y"
  146. that was still equal to zero.
  147. This example can be checked by running the following command, which
  148. absolutely must be run from the tools/memory-model directory and from
  149. this directory only:
  150. herd7 -conf linux-kernel.cfg litmus-tests/MP+pooncerelease+poacquireonce.litmus
  151. The output is the result of something similar to a full state-space
  152. search, and is as follows:
  153. 1 Test MP+pooncerelease+poacquireonce Allowed
  154. 2 States 3
  155. 3 1:r0=0; 1:r1=0;
  156. 4 1:r0=0; 1:r1=1;
  157. 5 1:r0=1; 1:r1=1;
  158. 6 No
  159. 7 Witnesses
  160. 8 Positive: 0 Negative: 3
  161. 9 Condition exists (1:r0=1 /\ 1:r1=0)
  162. 10 Observation MP+pooncerelease+poacquireonce Never 0 3
  163. 11 Time MP+pooncerelease+poacquireonce 0.00
  164. 12 Hash=579aaa14d8c35a39429b02e698241d09
  165. The most pertinent line is line 10, which contains "Never 0 3", which
  166. indicates that the bad result flagged by the "exists" clause never
  167. happens. This line might instead say "Sometimes" to indicate that the
  168. bad result happened in some but not all executions, or it might say
  169. "Always" to indicate that the bad result happened in all executions.
  170. (The herd7 tool doesn't judge, so it is only an LKMM convention that the
  171. "exists" clause indicates a bad result. To see this, invert the "exists"
  172. clause's condition and run the test.) The numbers ("0 3") at the end
  173. of this line indicate the number of end states satisfying the "exists"
  174. clause (0) and the number not not satisfying that clause (3).
  175. Another important part of this output is shown in lines 2-5, repeated here:
  176. 2 States 3
  177. 3 1:r0=0; 1:r1=0;
  178. 4 1:r0=0; 1:r1=1;
  179. 5 1:r0=1; 1:r1=1;
  180. Line 2 gives the total number of end states, and each of lines 3-5 list
  181. one of these states, with the first ("1:r0=0; 1:r1=0;") indicating that
  182. both of P1()'s loads returned the value "0". As expected, given the
  183. "Never" on line 10, the state flagged by the "exists" clause is not
  184. listed. This full list of states can be helpful when debugging a new
  185. litmus test.
  186. The rest of the output is not normally needed, either due to irrelevance
  187. or due to being redundant with the lines discussed above. However, the
  188. following paragraph lists them for the benefit of readers possessed of
  189. an insatiable curiosity. Other readers should feel free to skip ahead.
  190. Line 1 echos the test name, along with the "Test" and "Allowed". Line 6's
  191. "No" says that the "exists" clause was not satisfied by any execution,
  192. and as such it has the same meaning as line 10's "Never". Line 7 is a
  193. lead-in to line 8's "Positive: 0 Negative: 3", which lists the number
  194. of end states satisfying and not satisfying the "exists" clause, just
  195. like the two numbers at the end of line 10. Line 9 repeats the "exists"
  196. clause so that you don't have to look it up in the litmus-test file.
  197. The number at the end of line 11 (which begins with "Time") gives the
  198. time in seconds required to analyze the litmus test. Small tests such
  199. as this one complete in a few milliseconds, so "0.00" is quite common.
  200. Line 12 gives a hash of the contents for the litmus-test file, and is used
  201. by tooling that manages litmus tests and their output. This tooling is
  202. used by people modifying LKMM itself, and among other things lets such
  203. people know which of the several thousand relevant litmus tests were
  204. affected by a given change to LKMM.
  205. Initialization
  206. --------------
  207. The previous example relied on the default zero initialization for
  208. "x" and "y", but a similar litmus test could instead initialize them
  209. to some other value:
  210. 1 C MP+pooncerelease+poacquireonce
  211. 2
  212. 3 {
  213. 4 x=42;
  214. 5 y=42;
  215. 6 }
  216. 7
  217. 8 P0(int *x, int *y)
  218. 9 {
  219. 10 WRITE_ONCE(*x, 1);
  220. 11 smp_store_release(y, 1);
  221. 12 }
  222. 13
  223. 14 P1(int *x, int *y)
  224. 15 {
  225. 16 int r0;
  226. 17 int r1;
  227. 18
  228. 19 r0 = smp_load_acquire(y);
  229. 20 r1 = READ_ONCE(*x);
  230. 21 }
  231. 22
  232. 23 exists (1:r0=1 /\ 1:r1=42)
  233. Lines 3-6 now initialize both "x" and "y" to the value 42. This also
  234. means that the "exists" clause on line 23 must change "1:r1=0" to
  235. "1:r1=42".
  236. Running the test gives the same overall result as before, but with the
  237. value 42 appearing in place of the value zero:
  238. 1 Test MP+pooncerelease+poacquireonce Allowed
  239. 2 States 3
  240. 3 1:r0=1; 1:r1=1;
  241. 4 1:r0=42; 1:r1=1;
  242. 5 1:r0=42; 1:r1=42;
  243. 6 No
  244. 7 Witnesses
  245. 8 Positive: 0 Negative: 3
  246. 9 Condition exists (1:r0=1 /\ 1:r1=42)
  247. 10 Observation MP+pooncerelease+poacquireonce Never 0 3
  248. 11 Time MP+pooncerelease+poacquireonce 0.02
  249. 12 Hash=ab9a9b7940a75a792266be279a980156
  250. It is tempting to avoid the open-coded repetitions of the value "42"
  251. by defining another global variable "initval=42" and replacing all
  252. occurrences of "42" with "initval". This will not, repeat *not*,
  253. initialize "x" and "y" to 42, but instead to the address of "initval"
  254. (try it!). See the section below on linked lists to learn more about
  255. why this approach to initialization can be useful.
  256. Control Structures
  257. ------------------
  258. LKMM supports the C-language "if" statement, which allows modeling of
  259. conditional branches. In LKMM, conditional branches can affect ordering,
  260. but only if you are *very* careful (compilers are surprisingly able
  261. to optimize away conditional branches). The following example shows
  262. the "load buffering" (LB) use case that is used in the Linux kernel to
  263. synchronize between ring-buffer producers and consumers. In the example
  264. below, P0() is one side checking to see if an operation may proceed and
  265. P1() is the other side completing its update.
  266. 1 C LB+fencembonceonce+ctrlonceonce
  267. 2
  268. 3 {}
  269. 4
  270. 5 P0(int *x, int *y)
  271. 6 {
  272. 7 int r0;
  273. 8
  274. 9 r0 = READ_ONCE(*x);
  275. 10 if (r0)
  276. 11 WRITE_ONCE(*y, 1);
  277. 12 }
  278. 13
  279. 14 P1(int *x, int *y)
  280. 15 {
  281. 16 int r0;
  282. 17
  283. 18 r0 = READ_ONCE(*y);
  284. 19 smp_mb();
  285. 20 WRITE_ONCE(*x, 1);
  286. 21 }
  287. 22
  288. 23 exists (0:r0=1 /\ 1:r0=1)
  289. P1()'s "if" statement on line 10 works as expected, so that line 11 is
  290. executed only if line 9 loads a non-zero value from "x". Because P1()'s
  291. write of "1" to "x" happens only after P1()'s read from "y", one would
  292. hope that the "exists" clause cannot be satisfied. LKMM agrees:
  293. 1 Test LB+fencembonceonce+ctrlonceonce Allowed
  294. 2 States 2
  295. 3 0:r0=0; 1:r0=0;
  296. 4 0:r0=1; 1:r0=0;
  297. 5 No
  298. 6 Witnesses
  299. 7 Positive: 0 Negative: 2
  300. 8 Condition exists (0:r0=1 /\ 1:r0=1)
  301. 9 Observation LB+fencembonceonce+ctrlonceonce Never 0 2
  302. 10 Time LB+fencembonceonce+ctrlonceonce 0.00
  303. 11 Hash=e5260556f6de495fd39b556d1b831c3b
  304. However, there is no "while" statement due to the fact that full
  305. state-space search has some difficulty with iteration. However, there
  306. are tricks that may be used to handle some special cases, which are
  307. discussed below. In addition, loop-unrolling tricks may be applied,
  308. albeit sparingly.
  309. Tricks and Traps
  310. ================
  311. This section covers extracting debug output from herd7, emulating
  312. spin loops, handling trivial linked lists, adding comments to litmus tests,
  313. emulating call_rcu(), and finally tricks to improve herd7 performance
  314. in order to better handle large litmus tests.
  315. Debug Output
  316. ------------
  317. By default, the herd7 state output includes all variables mentioned
  318. in the "exists" clause. But sometimes debugging efforts are greatly
  319. aided by the values of other variables. Consider this litmus test
  320. (tools/memory-order/litmus-tests/SB+rfionceonce-poonceonces.litmus but
  321. slightly modified), which probes an obscure corner of hardware memory
  322. ordering:
  323. 1 C SB+rfionceonce-poonceonces
  324. 2
  325. 3 {}
  326. 4
  327. 5 P0(int *x, int *y)
  328. 6 {
  329. 7 int r1;
  330. 8 int r2;
  331. 9
  332. 10 WRITE_ONCE(*x, 1);
  333. 11 r1 = READ_ONCE(*x);
  334. 12 r2 = READ_ONCE(*y);
  335. 13 }
  336. 14
  337. 15 P1(int *x, int *y)
  338. 16 {
  339. 17 int r3;
  340. 18 int r4;
  341. 19
  342. 20 WRITE_ONCE(*y, 1);
  343. 21 r3 = READ_ONCE(*y);
  344. 22 r4 = READ_ONCE(*x);
  345. 23 }
  346. 24
  347. 25 exists (0:r2=0 /\ 1:r4=0)
  348. The herd7 output is as follows:
  349. 1 Test SB+rfionceonce-poonceonces Allowed
  350. 2 States 4
  351. 3 0:r2=0; 1:r4=0;
  352. 4 0:r2=0; 1:r4=1;
  353. 5 0:r2=1; 1:r4=0;
  354. 6 0:r2=1; 1:r4=1;
  355. 7 Ok
  356. 8 Witnesses
  357. 9 Positive: 1 Negative: 3
  358. 10 Condition exists (0:r2=0 /\ 1:r4=0)
  359. 11 Observation SB+rfionceonce-poonceonces Sometimes 1 3
  360. 12 Time SB+rfionceonce-poonceonces 0.01
  361. 13 Hash=c7f30fe0faebb7d565405d55b7318ada
  362. (This output indicates that CPUs are permitted to "snoop their own
  363. store buffers", which all of Linux's CPU families other than s390 will
  364. happily do. Such snooping results in disagreement among CPUs on the
  365. order of stores from different CPUs, which is rarely an issue.)
  366. But the herd7 output shows only the two variables mentioned in the
  367. "exists" clause. Someone modifying this test might wish to know the
  368. values of "x", "y", "0:r1", and "0:r3" as well. The "locations"
  369. statement on line 25 shows how to cause herd7 to display additional
  370. variables:
  371. 1 C SB+rfionceonce-poonceonces
  372. 2
  373. 3 {}
  374. 4
  375. 5 P0(int *x, int *y)
  376. 6 {
  377. 7 int r1;
  378. 8 int r2;
  379. 9
  380. 10 WRITE_ONCE(*x, 1);
  381. 11 r1 = READ_ONCE(*x);
  382. 12 r2 = READ_ONCE(*y);
  383. 13 }
  384. 14
  385. 15 P1(int *x, int *y)
  386. 16 {
  387. 17 int r3;
  388. 18 int r4;
  389. 19
  390. 20 WRITE_ONCE(*y, 1);
  391. 21 r3 = READ_ONCE(*y);
  392. 22 r4 = READ_ONCE(*x);
  393. 23 }
  394. 24
  395. 25 locations [0:r1; 1:r3; x; y]
  396. 26 exists (0:r2=0 /\ 1:r4=0)
  397. The herd7 output then displays the values of all the variables:
  398. 1 Test SB+rfionceonce-poonceonces Allowed
  399. 2 States 4
  400. 3 0:r1=1; 0:r2=0; 1:r3=1; 1:r4=0; x=1; y=1;
  401. 4 0:r1=1; 0:r2=0; 1:r3=1; 1:r4=1; x=1; y=1;
  402. 5 0:r1=1; 0:r2=1; 1:r3=1; 1:r4=0; x=1; y=1;
  403. 6 0:r1=1; 0:r2=1; 1:r3=1; 1:r4=1; x=1; y=1;
  404. 7 Ok
  405. 8 Witnesses
  406. 9 Positive: 1 Negative: 3
  407. 10 Condition exists (0:r2=0 /\ 1:r4=0)
  408. 11 Observation SB+rfionceonce-poonceonces Sometimes 1 3
  409. 12 Time SB+rfionceonce-poonceonces 0.01
  410. 13 Hash=40de8418c4b395388f6501cafd1ed38d
  411. What if you would like to know the value of a particular global variable
  412. at some particular point in a given process's execution? One approach
  413. is to use a READ_ONCE() to load that global variable into a new local
  414. variable, then add that local variable to the "locations" clause.
  415. But be careful: In some litmus tests, adding a READ_ONCE() will change
  416. the outcome! For one example, please see the C-READ_ONCE.litmus and
  417. C-READ_ONCE-omitted.litmus tests located here:
  418. https://github.com/paulmckrcu/litmus/blob/master/manual/kernel/
  419. Spin Loops
  420. ----------
  421. The analysis carried out by herd7 explores full state space, which is
  422. at best of exponential time complexity. Adding processes and increasing
  423. the amount of code in a give process can greatly increase execution time.
  424. Potentially infinite loops, such as those used to wait for locks to
  425. become available, are clearly problematic.
  426. Fortunately, it is possible to avoid state-space explosion by specially
  427. modeling such loops. For example, the following litmus tests emulates
  428. locking using xchg_acquire(), but instead of enclosing xchg_acquire()
  429. in a spin loop, it instead excludes executions that fail to acquire the
  430. lock using a herd7 "filter" clause. Note that for exclusive locking, you
  431. are better off using the spin_lock() and spin_unlock() that LKMM directly
  432. models, if for no other reason that these are much faster. However, the
  433. techniques illustrated in this section can be used for other purposes,
  434. such as emulating reader-writer locking, which LKMM does not yet model.
  435. 1 C C-SB+l-o-o-u+l-o-o-u-X
  436. 2
  437. 3 {
  438. 4 }
  439. 5
  440. 6 P0(int *sl, int *x0, int *x1)
  441. 7 {
  442. 8 int r2;
  443. 9 int r1;
  444. 10
  445. 11 r2 = xchg_acquire(sl, 1);
  446. 12 WRITE_ONCE(*x0, 1);
  447. 13 r1 = READ_ONCE(*x1);
  448. 14 smp_store_release(sl, 0);
  449. 15 }
  450. 16
  451. 17 P1(int *sl, int *x0, int *x1)
  452. 18 {
  453. 19 int r2;
  454. 20 int r1;
  455. 21
  456. 22 r2 = xchg_acquire(sl, 1);
  457. 23 WRITE_ONCE(*x1, 1);
  458. 24 r1 = READ_ONCE(*x0);
  459. 25 smp_store_release(sl, 0);
  460. 26 }
  461. 27
  462. 28 filter (0:r2=0 /\ 1:r2=0)
  463. 29 exists (0:r1=0 /\ 1:r1=0)
  464. This litmus test may be found here:
  465. https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/perfbook.git/tree/CodeSamples/formal/herd/C-SB+l-o-o-u+l-o-o-u-X.litmus
  466. This test uses two global variables, "x1" and "x2", and also emulates a
  467. single global spinlock named "sl". This spinlock is held by whichever
  468. process changes the value of "sl" from "0" to "1", and is released when
  469. that process sets "sl" back to "0". P0()'s lock acquisition is emulated
  470. on line 11 using xchg_acquire(), which unconditionally stores the value
  471. "1" to "sl" and stores either "0" or "1" to "r2", depending on whether
  472. the lock acquisition was successful or unsuccessful (due to "sl" already
  473. having the value "1"), respectively. P1() operates in a similar manner.
  474. Rather unconventionally, execution appears to proceed to the critical
  475. section on lines 12 and 13 in either case. Line 14 then uses an
  476. smp_store_release() to store zero to "sl", thus emulating lock release.
  477. The case where xchg_acquire() fails to acquire the lock is handled by
  478. the "filter" clause on line 28, which tells herd7 to keep only those
  479. executions in which both "0:r2" and "1:r2" are zero, that is to pay
  480. attention only to those executions in which both locks are actually
  481. acquired. Thus, the bogus executions that would execute the critical
  482. sections are discarded and any effects that they might have had are
  483. ignored. Note well that the "filter" clause keeps those executions
  484. for which its expression is satisfied, that is, for which the expression
  485. evaluates to true. In other words, the "filter" clause says what to
  486. keep, not what to discard.
  487. The result of running this test is as follows:
  488. 1 Test C-SB+l-o-o-u+l-o-o-u-X Allowed
  489. 2 States 2
  490. 3 0:r1=0; 1:r1=1;
  491. 4 0:r1=1; 1:r1=0;
  492. 5 No
  493. 6 Witnesses
  494. 7 Positive: 0 Negative: 2
  495. 8 Condition exists (0:r1=0 /\ 1:r1=0)
  496. 9 Observation C-SB+l-o-o-u+l-o-o-u-X Never 0 2
  497. 10 Time C-SB+l-o-o-u+l-o-o-u-X 0.03
  498. The "Never" on line 9 indicates that this use of xchg_acquire() and
  499. smp_store_release() really does correctly emulate locking.
  500. Why doesn't the litmus test take the simpler approach of using a spin loop
  501. to handle failed spinlock acquisitions, like the kernel does? The key
  502. insight behind this litmus test is that spin loops have no effect on the
  503. possible "exists"-clause outcomes of program execution in the absence
  504. of deadlock. In other words, given a high-quality lock-acquisition
  505. primitive in a deadlock-free program running on high-quality hardware,
  506. each lock acquisition will eventually succeed. Because herd7 already
  507. explores the full state space, the length of time required to actually
  508. acquire the lock does not matter. After all, herd7 already models all
  509. possible durations of the xchg_acquire() statements.
  510. Why not just add the "filter" clause to the "exists" clause, thus
  511. avoiding the "filter" clause entirely? This does work, but is slower.
  512. The reason that the "filter" clause is faster is that (in the common case)
  513. herd7 knows to abandon an execution as soon as the "filter" expression
  514. fails to be satisfied. In contrast, the "exists" clause is evaluated
  515. only at the end of time, thus requiring herd7 to waste time on bogus
  516. executions in which both critical sections proceed concurrently. In
  517. addition, some LKMM users like the separation of concerns provided by
  518. using the both the "filter" and "exists" clauses.
  519. Readers lacking a pathological interest in odd corner cases should feel
  520. free to skip the remainder of this section.
  521. But what if the litmus test were to temporarily set "0:r2" to a non-zero
  522. value? Wouldn't that cause herd7 to abandon the execution prematurely
  523. due to an early mismatch of the "filter" clause?
  524. Why not just try it? Line 4 of the following modified litmus test
  525. introduces a new global variable "x2" that is initialized to "1". Line 23
  526. of P1() reads that variable into "1:r2" to force an early mismatch with
  527. the "filter" clause. Line 24 does a known-true "if" condition to avoid
  528. and static analysis that herd7 might do. Finally the "exists" clause
  529. on line 32 is updated to a condition that is alway satisfied at the end
  530. of the test.
  531. 1 C C-SB+l-o-o-u+l-o-o-u-X
  532. 2
  533. 3 {
  534. 4 x2=1;
  535. 5 }
  536. 6
  537. 7 P0(int *sl, int *x0, int *x1)
  538. 8 {
  539. 9 int r2;
  540. 10 int r1;
  541. 11
  542. 12 r2 = xchg_acquire(sl, 1);
  543. 13 WRITE_ONCE(*x0, 1);
  544. 14 r1 = READ_ONCE(*x1);
  545. 15 smp_store_release(sl, 0);
  546. 16 }
  547. 17
  548. 18 P1(int *sl, int *x0, int *x1, int *x2)
  549. 19 {
  550. 20 int r2;
  551. 21 int r1;
  552. 22
  553. 23 r2 = READ_ONCE(*x2);
  554. 24 if (r2)
  555. 25 r2 = xchg_acquire(sl, 1);
  556. 26 WRITE_ONCE(*x1, 1);
  557. 27 r1 = READ_ONCE(*x0);
  558. 28 smp_store_release(sl, 0);
  559. 29 }
  560. 30
  561. 31 filter (0:r2=0 /\ 1:r2=0)
  562. 32 exists (x1=1)
  563. If the "filter" clause were to check each variable at each point in the
  564. execution, running this litmus test would display no executions because
  565. all executions would be filtered out at line 23. However, the output
  566. is instead as follows:
  567. 1 Test C-SB+l-o-o-u+l-o-o-u-X Allowed
  568. 2 States 1
  569. 3 x1=1;
  570. 4 Ok
  571. 5 Witnesses
  572. 6 Positive: 2 Negative: 0
  573. 7 Condition exists (x1=1)
  574. 8 Observation C-SB+l-o-o-u+l-o-o-u-X Always 2 0
  575. 9 Time C-SB+l-o-o-u+l-o-o-u-X 0.04
  576. 10 Hash=080bc508da7f291e122c6de76c0088e3
  577. Line 3 shows that there is one execution that did not get filtered out,
  578. so the "filter" clause is evaluated only on the last assignment to
  579. the variables that it checks. In this case, the "filter" clause is a
  580. disjunction, so it might be evaluated twice, once at the final (and only)
  581. assignment to "0:r2" and once at the final assignment to "1:r2".
  582. Linked Lists
  583. ------------
  584. LKMM can handle linked lists, but only linked lists in which each node
  585. contains nothing except a pointer to the next node in the list. This is
  586. of course quite restrictive, but there is nevertheless quite a bit that
  587. can be done within these confines, as can be seen in the litmus test
  588. at tools/memory-model/litmus-tests/MP+onceassign+derefonce.litmus:
  589. 1 C MP+onceassign+derefonce
  590. 2
  591. 3 {
  592. 4 y=z;
  593. 5 z=0;
  594. 6 }
  595. 7
  596. 8 P0(int *x, int **y)
  597. 9 {
  598. 10 WRITE_ONCE(*x, 1);
  599. 11 rcu_assign_pointer(*y, x);
  600. 12 }
  601. 13
  602. 14 P1(int *x, int **y)
  603. 15 {
  604. 16 int *r0;
  605. 17 int r1;
  606. 18
  607. 19 rcu_read_lock();
  608. 20 r0 = rcu_dereference(*y);
  609. 21 r1 = READ_ONCE(*r0);
  610. 22 rcu_read_unlock();
  611. 23 }
  612. 24
  613. 25 exists (1:r0=x /\ 1:r1=0)
  614. Line 4's "y=z" may seem odd, given that "z" has not yet been initialized.
  615. But "y=z" does not set the value of "y" to that of "z", but instead
  616. sets the value of "y" to the *address* of "z". Lines 4 and 5 therefore
  617. create a simple linked list, with "y" pointing to "z" and "z" having a
  618. NULL pointer. A much longer linked list could be created if desired,
  619. and circular singly linked lists can also be created and manipulated.
  620. The "exists" clause works the same way, with the "1:r0=x" comparing P1()'s
  621. "r0" not to the value of "x", but again to its address. This term of the
  622. "exists" clause therefore tests whether line 20's load from "y" saw the
  623. value stored by line 11, which is in fact what is required in this case.
  624. P0()'s line 10 initializes "x" to the value 1 then line 11 links to "x"
  625. from "y", replacing "z".
  626. P1()'s line 20 loads a pointer from "y", and line 21 dereferences that
  627. pointer. The RCU read-side critical section spanning lines 19-22 is just
  628. for show in this example. Note that the address used for line 21's load
  629. depends on (in this case, "is exactly the same as") the value loaded by
  630. line 20. This is an example of what is called an "address dependency".
  631. This particular address dependency extends from the load on line 20 to the
  632. load on line 21. Address dependencies provide a weak form of ordering.
  633. Running this test results in the following:
  634. 1 Test MP+onceassign+derefonce Allowed
  635. 2 States 2
  636. 3 1:r0=x; 1:r1=1;
  637. 4 1:r0=z; 1:r1=0;
  638. 5 No
  639. 6 Witnesses
  640. 7 Positive: 0 Negative: 2
  641. 8 Condition exists (1:r0=x /\ 1:r1=0)
  642. 9 Observation MP+onceassign+derefonce Never 0 2
  643. 10 Time MP+onceassign+derefonce 0.00
  644. 11 Hash=49ef7a741563570102448a256a0c8568
  645. The only possible outcomes feature P1() loading a pointer to "z"
  646. (which contains zero) on the one hand and P1() loading a pointer to "x"
  647. (which contains the value one) on the other. This should be reassuring
  648. because it says that RCU readers cannot see the old preinitialization
  649. values when accessing a newly inserted list node. This undesirable
  650. scenario is flagged by the "exists" clause, and would occur if P1()
  651. loaded a pointer to "x", but obtained the pre-initialization value of
  652. zero after dereferencing that pointer.
  653. Comments
  654. --------
  655. Different portions of a litmus test are processed by different parsers,
  656. which has the charming effect of requiring different comment syntax in
  657. different portions of the litmus test. The C-syntax portions use
  658. C-language comments (either "/* */" or "//"), while the other portions
  659. use Ocaml comments "(* *)".
  660. The following litmus test illustrates the comment style corresponding
  661. to each syntactic unit of the test:
  662. 1 C MP+onceassign+derefonce (* A *)
  663. 2
  664. 3 (* B *)
  665. 4
  666. 5 {
  667. 6 y=z; (* C *)
  668. 7 z=0;
  669. 8 } // D
  670. 9
  671. 10 // E
  672. 11
  673. 12 P0(int *x, int **y) // F
  674. 13 {
  675. 14 WRITE_ONCE(*x, 1); // G
  676. 15 rcu_assign_pointer(*y, x);
  677. 16 }
  678. 17
  679. 18 // H
  680. 19
  681. 20 P1(int *x, int **y)
  682. 21 {
  683. 22 int *r0;
  684. 23 int r1;
  685. 24
  686. 25 rcu_read_lock();
  687. 26 r0 = rcu_dereference(*y);
  688. 27 r1 = READ_ONCE(*r0);
  689. 28 rcu_read_unlock();
  690. 29 }
  691. 30
  692. 31 // I
  693. 32
  694. 33 exists (* J *) (1:r0=x /\ (* K *) 1:r1=0) (* L *)
  695. In short, use C-language comments in the C code and Ocaml comments in
  696. the rest of the litmus test.
  697. On the other hand, if you prefer C-style comments everywhere, the
  698. C preprocessor is your friend.
  699. Asynchronous RCU Grace Periods
  700. ------------------------------
  701. The following litmus test is derived from the example show in
  702. Documentation/litmus-tests/rcu/RCU+sync+free.litmus, but converted to
  703. emulate call_rcu():
  704. 1 C RCU+sync+free
  705. 2
  706. 3 {
  707. 4 int x = 1;
  708. 5 int *y = &x;
  709. 6 int z = 1;
  710. 7 }
  711. 8
  712. 9 P0(int *x, int *z, int **y)
  713. 10 {
  714. 11 int *r0;
  715. 12 int r1;
  716. 13
  717. 14 rcu_read_lock();
  718. 15 r0 = rcu_dereference(*y);
  719. 16 r1 = READ_ONCE(*r0);
  720. 17 rcu_read_unlock();
  721. 18 }
  722. 19
  723. 20 P1(int *z, int **y, int *c)
  724. 21 {
  725. 22 rcu_assign_pointer(*y, z);
  726. 23 smp_store_release(*c, 1); // Emulate call_rcu().
  727. 24 }
  728. 25
  729. 26 P2(int *x, int *z, int **y, int *c)
  730. 27 {
  731. 28 int r0;
  732. 29
  733. 30 r0 = smp_load_acquire(*c); // Note call_rcu() request.
  734. 31 synchronize_rcu(); // Wait one grace period.
  735. 32 WRITE_ONCE(*x, 0); // Emulate the RCU callback.
  736. 33 }
  737. 34
  738. 35 filter (2:r0=1) (* Reject too-early starts. *)
  739. 36 exists (0:r0=x /\ 0:r1=0)
  740. Lines 4-6 initialize a linked list headed by "y" that initially contains
  741. "x". In addition, "z" is pre-initialized to prepare for P1(), which
  742. will replace "x" with "z" in this list.
  743. P0() on lines 9-18 enters an RCU read-side critical section, loads the
  744. list header "y" and dereferences it, leaving the node in "0:r0" and
  745. the node's value in "0:r1".
  746. P1() on lines 20-24 updates the list header to instead reference "z",
  747. then emulates call_rcu() by doing a release store into "c".
  748. P2() on lines 27-33 emulates the behind-the-scenes effect of doing a
  749. call_rcu(). Line 30 first does an acquire load from "c", then line 31
  750. waits for an RCU grace period to elapse, and finally line 32 emulates
  751. the RCU callback, which in turn emulates a call to kfree().
  752. Of course, it is possible for P2() to start too soon, so that the
  753. value of "2:r0" is zero rather than the required value of "1".
  754. The "filter" clause on line 35 handles this possibility, rejecting
  755. all executions in which "2:r0" is not equal to the value "1".
  756. Performance
  757. -----------
  758. LKMM's exploration of the full state-space can be extremely helpful,
  759. but it does not come for free. The price is exponential computational
  760. complexity in terms of the number of processes, the average number
  761. of statements in each process, and the total number of stores in the
  762. litmus test.
  763. So it is best to start small and then work up. Where possible, break
  764. your code down into small pieces each representing a core concurrency
  765. requirement.
  766. That said, herd7 is quite fast. On an unprepossessing x86 laptop, it
  767. was able to analyze the following 10-process RCU litmus test in about
  768. six seconds.
  769. https://github.com/paulmckrcu/litmus/blob/master/auto/C-RW-R+RW-R+RW-G+RW-G+RW-G+RW-G+RW-R+RW-R+RW-R+RW-R.litmus
  770. One way to make herd7 run faster is to use the "-speedcheck true" option.
  771. This option prevents herd7 from generating all possible end states,
  772. instead causing it to focus solely on whether or not the "exists"
  773. clause can be satisfied. With this option, herd7 evaluates the above
  774. litmus test in about 300 milliseconds, for more than an order of magnitude
  775. improvement in performance.
  776. Larger 16-process litmus tests that would normally consume 15 minutes
  777. of time complete in about 40 seconds with this option. To be fair,
  778. you do get an extra 65,535 states when you leave off the "-speedcheck
  779. true" option.
  780. https://github.com/paulmckrcu/litmus/blob/master/auto/C-RW-R+RW-R+RW-G+RW-G+RW-G+RW-G+RW-R+RW-R+RW-R+RW-R+RW-G+RW-G+RW-G+RW-G+RW-R+RW-R.litmus
  781. Nevertheless, litmus-test analysis really is of exponential complexity,
  782. whether with or without "-speedcheck true". Increasing by just three
  783. processes to a 19-process litmus test requires 2 hours and 40 minutes
  784. without, and about 8 minutes with "-speedcheck true". Each of these
  785. results represent roughly an order of magnitude slowdown compared to the
  786. 16-process litmus test. Again, to be fair, the multi-hour run explores
  787. no fewer than 524,287 additional states compared to the shorter one.
  788. https://github.com/paulmckrcu/litmus/blob/master/auto/C-RW-R+RW-R+RW-G+RW-G+RW-G+RW-G+RW-R+RW-R+RW-R+RW-R+RW-R+RW-R+RW-G+RW-G+RW-G+RW-G+RW-R+RW-R+RW-R.litmus
  789. If you don't like command-line arguments, you can obtain a similar speedup
  790. by adding a "filter" clause with exactly the same expression as your
  791. "exists" clause.
  792. However, please note that seeing the full set of states can be extremely
  793. helpful when developing and debugging litmus tests.
  794. LIMITATIONS
  795. ===========
  796. Limitations of the Linux-kernel memory model (LKMM) include:
  797. 1. Compiler optimizations are not accurately modeled. Of course,
  798. the use of READ_ONCE() and WRITE_ONCE() limits the compiler's
  799. ability to optimize, but under some circumstances it is possible
  800. for the compiler to undermine the memory model. For more
  801. information, see Documentation/explanation.txt (in particular,
  802. the "THE PROGRAM ORDER RELATION: po AND po-loc" and "A WARNING"
  803. sections).
  804. Note that this limitation in turn limits LKMM's ability to
  805. accurately model address, control, and data dependencies.
  806. For example, if the compiler can deduce the value of some variable
  807. carrying a dependency, then the compiler can break that dependency
  808. by substituting a constant of that value.
  809. Conversely, LKMM will sometimes overestimate the amount of
  810. reordering compilers and CPUs can carry out, leading it to miss
  811. some pretty obvious cases of ordering. A simple example is:
  812. r1 = READ_ONCE(x);
  813. if (r1 == 0)
  814. smp_mb();
  815. WRITE_ONCE(y, 1);
  816. The WRITE_ONCE() does not depend on the READ_ONCE(), and as a
  817. result, LKMM does not claim ordering. However, even though no
  818. dependency is present, the WRITE_ONCE() will not be executed before
  819. the READ_ONCE(). There are two reasons for this:
  820. The presence of the smp_mb() in one of the branches
  821. prevents the compiler from moving the WRITE_ONCE()
  822. up before the "if" statement, since the compiler has
  823. to assume that r1 will sometimes be 0 (but see the
  824. comment below);
  825. CPUs do not execute stores before po-earlier conditional
  826. branches, even in cases where the store occurs after the
  827. two arms of the branch have recombined.
  828. It is clear that it is not dangerous in the slightest for LKMM to
  829. make weaker guarantees than architectures. In fact, it is
  830. desirable, as it gives compilers room for making optimizations.
  831. For instance, suppose that a 0 value in r1 would trigger undefined
  832. behavior elsewhere. Then a clever compiler might deduce that r1
  833. can never be 0 in the if condition. As a result, said clever
  834. compiler might deem it safe to optimize away the smp_mb(),
  835. eliminating the branch and any ordering an architecture would
  836. guarantee otherwise.
  837. 2. Multiple access sizes for a single variable are not supported,
  838. and neither are misaligned or partially overlapping accesses.
  839. 3. Exceptions and interrupts are not modeled. In some cases,
  840. this limitation can be overcome by modeling the interrupt or
  841. exception with an additional process.
  842. 4. I/O such as MMIO or DMA is not supported.
  843. 5. Self-modifying code (such as that found in the kernel's
  844. alternatives mechanism, function tracer, Berkeley Packet Filter
  845. JIT compiler, and module loader) is not supported.
  846. 6. Complete modeling of all variants of atomic read-modify-write
  847. operations, locking primitives, and RCU is not provided.
  848. For example, call_rcu() and rcu_barrier() are not supported.
  849. However, a substantial amount of support is provided for these
  850. operations, as shown in the linux-kernel.def file.
  851. Here are specific limitations:
  852. a. When rcu_assign_pointer() is passed NULL, the Linux
  853. kernel provides no ordering, but LKMM models this
  854. case as a store release.
  855. b. The "unless" RMW operations are not currently modeled:
  856. atomic_long_add_unless(), atomic_inc_unless_negative(),
  857. and atomic_dec_unless_positive(). These can be emulated
  858. in litmus tests, for example, by using atomic_cmpxchg().
  859. One exception of this limitation is atomic_add_unless(),
  860. which is provided directly by herd7 (so no corresponding
  861. definition in linux-kernel.def). atomic_add_unless() is
  862. modeled by herd7 therefore it can be used in litmus tests.
  863. c. The call_rcu() function is not modeled. As was shown above,
  864. it can be emulated in litmus tests by adding another
  865. process that invokes synchronize_rcu() and the body of the
  866. callback function, with (for example) a release-acquire
  867. from the site of the emulated call_rcu() to the beginning
  868. of the additional process.
  869. d. The rcu_barrier() function is not modeled. It can be
  870. emulated in litmus tests emulating call_rcu() via
  871. (for example) a release-acquire from the end of each
  872. additional call_rcu() process to the site of the
  873. emulated rcu-barrier().
  874. e. Although sleepable RCU (SRCU) is now modeled, there
  875. are some subtle differences between its semantics and
  876. those in the Linux kernel. For example, the kernel
  877. might interpret the following sequence as two partially
  878. overlapping SRCU read-side critical sections:
  879. 1 r1 = srcu_read_lock(&my_srcu);
  880. 2 do_something_1();
  881. 3 r2 = srcu_read_lock(&my_srcu);
  882. 4 do_something_2();
  883. 5 srcu_read_unlock(&my_srcu, r1);
  884. 6 do_something_3();
  885. 7 srcu_read_unlock(&my_srcu, r2);
  886. In contrast, LKMM will interpret this as a nested pair of
  887. SRCU read-side critical sections, with the outer critical
  888. section spanning lines 1-7 and the inner critical section
  889. spanning lines 3-5.
  890. This difference would be more of a concern had anyone
  891. identified a reasonable use case for partially overlapping
  892. SRCU read-side critical sections. For more information
  893. on the trickiness of such overlapping, please see:
  894. https://paulmck.livejournal.com/40593.html
  895. f. Reader-writer locking is not modeled. It can be
  896. emulated in litmus tests using atomic read-modify-write
  897. operations.
  898. The fragment of the C language supported by these litmus tests is quite
  899. limited and in some ways non-standard:
  900. 1. There is no automatic C-preprocessor pass. You can of course
  901. run it manually, if you choose.
  902. 2. There is no way to create functions other than the Pn() functions
  903. that model the concurrent processes.
  904. 3. The Pn() functions' formal parameters must be pointers to the
  905. global shared variables. Nothing can be passed by value into
  906. these functions.
  907. 4. The only functions that can be invoked are those built directly
  908. into herd7 or that are defined in the linux-kernel.def file.
  909. 5. The "switch", "do", "for", "while", and "goto" C statements are
  910. not supported. The "switch" statement can be emulated by the
  911. "if" statement. The "do", "for", and "while" statements can
  912. often be emulated by manually unrolling the loop, or perhaps by
  913. enlisting the aid of the C preprocessor to minimize the resulting
  914. code duplication. Some uses of "goto" can be emulated by "if",
  915. and some others by unrolling.
  916. 6. Although you can use a wide variety of types in litmus-test
  917. variable declarations, and especially in global-variable
  918. declarations, the "herd7" tool understands only int and
  919. pointer types. There is no support for floating-point types,
  920. enumerations, characters, strings, arrays, or structures.
  921. 7. Parsing of variable declarations is very loose, with almost no
  922. type checking.
  923. 8. Initializers differ from their C-language counterparts.
  924. For example, when an initializer contains the name of a shared
  925. variable, that name denotes a pointer to that variable, not
  926. the current value of that variable. For example, "int x = y"
  927. is interpreted the way "int x = &y" would be in C.
  928. 9. Dynamic memory allocation is not supported, although this can
  929. be worked around in some cases by supplying multiple statically
  930. allocated variables.
  931. Some of these limitations may be overcome in the future, but others are
  932. more likely to be addressed by incorporating the Linux-kernel memory model
  933. into other tools.
  934. Finally, please note that LKMM is subject to change as hardware, use cases,
  935. and compilers evolve.