Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools/memory-model: Finish the removal of rb-dep, smp_read_barrier_depends(), and lockless_dereference()

Commit:

bf28ae562744 ("tools/memory-model: Remove rb-dep, smp_read_barrier_depends, and lockless_dereference")

was merged too early, while it was still in RFC form. This patch adds in
the missing pieces.

Akira pointed out some typos in the original patch, and he noted that
cheatsheet.txt should indicate that READ_ONCE() now implies an address
dependency. Andrea suggested documenting the relationship betwwen
unsuccessful RMW operations and address dependencies.

Andrea pointed out that the macro for rcu_dereference() in linux.def
should now use the "once" annotation instead of "deref". He also
suggested that the comments should mention commit:

5a8897cc7631 ("locking/atomics/alpha: Add smp_read_barrier_depends() to _release()/_relaxed() atomics")

... as an important precursor, and he contributed commit:

cb13b424e986 ("locking/xchg/alpha: Add unconditional memory barrier to cmpxchg()")

which is another prerequisite.

Suggested-by: Akira Yokosawa <akiyks@gmail.com>
Suggested-by: Andrea Parri <parri.andrea@gmail.com>
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
[ Fixed read_read_lock() typo reported by Akira. ]
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Acked-by: Andrea Parri <parri.andrea@gmail.com>
Acked-by: Akira Yokosawa <akiyks@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: boqun.feng@gmail.com
Cc: dhowells@redhat.com
Cc: j.alglave@ucl.ac.uk
Cc: linux-arch@vger.kernel.org
Cc: luc.maranget@inria.fr
Cc: npiggin@gmail.com
Cc: will.deacon@arm.com
Fixes: bf28ae562744 ("tools/memory-model: Remove rb-dep, smp_read_barrier_depends, and lockless_dereference")
Link: http://lkml.kernel.org/r/1520443660-16858-4-git-send-email-paulmck@linux.vnet.ibm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Alan Stern and committed by
Ingo Molnar
bd5c0ba2 ff1fe5e0

+6 -6
+3 -3
tools/memory-model/Documentation/cheatsheet.txt
··· 1 1 Prior Operation Subsequent Operation 2 2 --------------- --------------------------- 3 3 C Self R W RWM Self R W DR DW RMW SV 4 - __ ---- - - --- ---- - - -- -- --- -- 4 + -- ---- - - --- ---- - - -- -- --- -- 5 5 6 6 Store, e.g., WRITE_ONCE() Y Y 7 - Load, e.g., READ_ONCE() Y Y Y 8 - Unsuccessful RMW operation Y Y Y 7 + Load, e.g., READ_ONCE() Y Y Y Y 8 + Unsuccessful RMW operation Y Y Y Y 9 9 rcu_dereference() Y Y Y Y 10 10 Successful *_acquire() R Y Y Y Y Y Y 11 11 Successful *_release() C Y Y Y W Y
+2 -2
tools/memory-model/Documentation/explanation.txt
··· 826 826 executed on C before the fence (i.e., those which precede the fence in 827 827 program order). 828 828 829 - read_lock(), rcu_read_unlock(), and synchronize_rcu() fences have 829 + rcu_read_lock(), rcu_read_unlock(), and synchronize_rcu() fences have 830 830 other properties which we discuss later. 831 831 832 832 ··· 1138 1138 program order, it appears that they aren't. 1139 1139 1140 1140 This could not have happened if the local cache had processed the 1141 - incoming stores in FIFO order. In constrast, other architectures 1141 + incoming stores in FIFO order. By contrast, other architectures 1142 1142 maintain at least the appearance of FIFO order. 1143 1143 1144 1144 In practice, this difficulty is solved by inserting a special fence
+1 -1
tools/memory-model/linux-kernel.def
··· 13 13 smp_store_release(X,V) { __store{release}(*X,V); } 14 14 smp_load_acquire(X) __load{acquire}(*X) 15 15 rcu_assign_pointer(X,V) { __store{release}(X,V); } 16 - rcu_dereference(X) __load{deref}(X) 16 + rcu_dereference(X) __load{once}(X) 17 17 18 18 // Fences 19 19 smp_mb() { __fence{mb} ; }