Skip to content

Commit 95bf376

Browse files
committed
Merge tag 'lkmm.2025.05.25a' of git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu
Pull lkmm updates from Paul McKenney: "Update LKMM documentation: - Cross-references, typos, broken URLs (Akira Yokosawa) - Clarify SRCU explanation (Uladzislau Rezki)" * tag 'lkmm.2025.05.25a' of git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu: tools/memory-model/Documentation: Fix SRCU section in explanation.txt tools/memory-model: docs/references: Remove broken link to imgtec.com tools/memory-model: docs/ordering: Fix trivial typos tools/memory-model: docs/simple.txt: Fix trivial typos tools/memory-model: docs/README: Update introduction of locking.txt
2 parents 97851c6 + 5c9e006 commit 95bf376

File tree

7 files changed

+29
-18
lines changed

7 files changed

+29
-18
lines changed

tools/memory-model/Documentation/README

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@ o You are familiar with the Linux-kernel concurrency primitives
2323
that you need, and just want to get started with LKMM litmus
2424
tests: litmus-tests.txt
2525

26-
o You would like to access lock-protected shared variables without
27-
having their corresponding locks held: locking.txt
26+
o You need to locklessly access shared variables that are otherwise
27+
protected by a lock: locking.txt
28+
29+
This locking.txt file expands on the "Locking" section in
30+
recipes.txt, but is self-contained.
2831

2932
o You are familiar with Linux-kernel concurrency, and would
3033
like a detailed intuitive understanding of LKMM, including

tools/memory-model/Documentation/explanation.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1896,7 +1896,7 @@ following respects:
18961896

18971897
3. The srcu_down_read() and srcu_up_read() primitives work
18981898
exactly like srcu_read_lock() and srcu_read_unlock(), except
1899-
that matching calls don't have to execute on the same CPU.
1899+
that matching calls don't have to execute within the same context.
19001900
(The names are meant to be suggestive of operations on
19011901
semaphores.) Since the matching is determined by the domain
19021902
pointer and index value, these primitives make it possible for

tools/memory-model/Documentation/locking.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
[!] Note:
2+
This file expands on the "Locking" section of recipes.txt,
3+
focusing on locklessly accessing shared variables that are
4+
otherwise protected by a lock.
5+
16
Locking
27
=======
38

tools/memory-model/Documentation/ordering.txt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ The Linux kernel's compiler barrier is barrier(). This primitive
223223
prohibits compiler code-motion optimizations that might move memory
224224
references across the point in the code containing the barrier(), but
225225
does not constrain hardware memory ordering. For example, this can be
226-
used to prevent to compiler from moving code across an infinite loop:
226+
used to prevent the compiler from moving code across an infinite loop:
227227

228228
WRITE_ONCE(x, 1);
229229
while (dontstop)
@@ -274,7 +274,7 @@ different pieces of the concurrent algorithm. The variable stored to
274274
by the smp_store_release(), in this case "y", will normally be used in
275275
an acquire operation in other parts of the concurrent algorithm.
276276

277-
To see the performance advantages, suppose that the above example read
277+
To see the performance advantages, suppose that the above example reads
278278
from "x" instead of writing to it. Then an smp_wmb() could not guarantee
279279
ordering, and an smp_mb() would be needed instead:
280280

@@ -394,17 +394,17 @@ from the value returned by the rcu_dereference() or srcu_dereference()
394394
to that subsequent memory access.
395395

396396
A call to rcu_dereference() for a given RCU-protected pointer is
397-
usually paired with a call to a call to rcu_assign_pointer() for that
398-
same pointer in much the same way that a call to smp_load_acquire() is
399-
paired with a call to smp_store_release(). Calls to rcu_dereference()
400-
and rcu_assign_pointer are often buried in other APIs, for example,
397+
usually paired with a call to rcu_assign_pointer() for that same pointer
398+
in much the same way that a call to smp_load_acquire() is paired with
399+
a call to smp_store_release(). Calls to rcu_dereference() and
400+
rcu_assign_pointer() are often buried in other APIs, for example,
401401
the RCU list API members defined in include/linux/rculist.h. For more
402402
information, please see the docbook headers in that file, the most
403-
recent LWN article on the RCU API (https://lwn.net/Articles/777036/),
403+
recent LWN article on the RCU API (https://lwn.net/Articles/988638/),
404404
and of course the material in Documentation/RCU.
405405

406406
If the pointer value is manipulated between the rcu_dereference()
407-
that returned it and a later dereference(), please read
407+
that returned it and a later rcu_dereference(), please read
408408
Documentation/RCU/rcu_dereference.rst. It can also be quite helpful to
409409
review uses in the Linux kernel.
410410

@@ -457,15 +457,15 @@ described earlier in this document.
457457
These operations come in three categories:
458458

459459
o Marked writes, such as WRITE_ONCE() and atomic_set(). These
460-
primitives required the compiler to emit the corresponding store
460+
primitives require the compiler to emit the corresponding store
461461
instructions in the expected execution order, thus suppressing
462462
a number of destructive optimizations. However, they provide no
463463
hardware ordering guarantees, and in fact many CPUs will happily
464464
reorder marked writes with each other or with other unordered
465465
operations, unless these operations are to the same variable.
466466

467467
o Marked reads, such as READ_ONCE() and atomic_read(). These
468-
primitives required the compiler to emit the corresponding load
468+
primitives require the compiler to emit the corresponding load
469469
instructions in the expected execution order, thus suppressing
470470
a number of destructive optimizations. However, they provide no
471471
hardware ordering guarantees, and in fact many CPUs will happily
@@ -506,7 +506,7 @@ of the old value and the new value.
506506

507507
Unmarked C-language accesses are unordered, and are also subject to
508508
any number of compiler optimizations, many of which can break your
509-
concurrent code. It is possible to used unmarked C-language accesses for
509+
concurrent code. It is possible to use unmarked C-language accesses for
510510
shared variables that are subject to concurrent access, but great care
511511
is required on an ongoing basis. The compiler-constraining barrier()
512512
primitive can be helpful, as can the various ordering primitives discussed

tools/memory-model/Documentation/recipes.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ usual) some things to be careful of:
6161
Locking
6262
-------
6363

64+
[!] Note:
65+
locking.txt expands on this section, providing more detail on
66+
locklessly accessing lock-protected shared variables.
67+
6468
Locking is well-known and straightforward, at least if you don't think
6569
about it too hard. And the basic rule is indeed quite simple: Any CPU that
6670
has acquired a given lock sees any changes previously seen or made by any

tools/memory-model/Documentation/references.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ o ARM Ltd. (Ed.). 2014. "ARM Architecture Reference Manual (ARMv8,
4646

4747
o Imagination Technologies, LTD. 2015. "MIPS(R) Architecture
4848
For Programmers, Volume II-A: The MIPS64(R) Instruction,
49-
Set Reference Manual". Imagination Technologies,
50-
LTD. https://imgtec.com/?do-download=4302.
49+
Set Reference Manual". Imagination Technologies, LTD.
5150

5251
o Shaked Flur, Kathryn E. Gray, Christopher Pulte, Susmit
5352
Sarkar, Ali Sezgin, Luc Maranget, Will Deacon, and Peter

tools/memory-model/Documentation/simple.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ Packaged primitives: Sequence locking
134134
Lockless programming is considered by many to be more difficult than
135135
lock-based programming, but there are a few lockless design patterns that
136136
have been built out into an API. One of these APIs is sequence locking.
137-
Although this APIs can be used in extremely complex ways, there are simple
137+
Although this API can be used in extremely complex ways, there are simple
138138
and effective ways of using it that avoid the need to pay attention to
139139
memory ordering.
140140

@@ -205,7 +205,7 @@ If you want to keep things simple, use the initialization and read-out
205205
operations from the previous section only when there are no racing
206206
accesses. Otherwise, use only fully ordered operations when accessing
207207
or modifying the variable. This approach guarantees that code prior
208-
to a given access to that variable will be seen by all CPUs has having
208+
to a given access to that variable will be seen by all CPUs as having
209209
happened before any code following any later access to that same variable.
210210

211211
Please note that per-CPU functions are not atomic operations and

0 commit comments

Comments
 (0)