mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
locking/atomics: COCCINELLE/treewide: Convert trivial ACCESS_ONCE() patterns to READ_ONCE()/WRITE_ONCE()
Please do not apply this to mainline directly, instead please re-run the coccinelle script shown below and apply its output. For several reasons, it is desirable to use {READ,WRITE}_ONCE() in preference to ACCESS_ONCE(), and new code is expected to use one of the former. So far, there's been no reason to change most existing uses of ACCESS_ONCE(), as these aren't harmful, and changing them results in churn. However, for some features, the read/write distinction is critical to correct operation. To distinguish these cases, separate read/write accessors must be used. This patch migrates (most) remaining ACCESS_ONCE() instances to {READ,WRITE}_ONCE(), using the following coccinelle script: ---- // Convert trivial ACCESS_ONCE() uses to equivalent READ_ONCE() and // WRITE_ONCE() // $ make coccicheck COCCI=/home/mark/once.cocci SPFLAGS="--include-headers" MODE=patch virtual patch @ depends on patch @ expression E1, E2; @@ - ACCESS_ONCE(E1) = E2 + WRITE_ONCE(E1, E2) @ depends on patch @ expression E; @@ - ACCESS_ONCE(E) + READ_ONCE(E) ---- Signed-off-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: davem@davemloft.net Cc: linux-arch@vger.kernel.org Cc: mpe@ellerman.id.au Cc: shuah@kernel.org Cc: snitzer@redhat.com Cc: thor.thayer@linux.intel.com Cc: tj@kernel.org Cc: viro@zeniv.linux.org.uk Cc: will.deacon@arm.com Link: http://lkml.kernel.org/r/1508792849-3115-19-git-send-email-paulmck@linux.vnet.ibm.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
parent
b03a0fe0c5
commit
6aa7de0591
180 changed files with 383 additions and 385 deletions
|
@ -39,7 +39,7 @@ begin_node:
|
|||
/* Descend through a shortcut */
|
||||
shortcut = assoc_array_ptr_to_shortcut(cursor);
|
||||
smp_read_barrier_depends();
|
||||
cursor = ACCESS_ONCE(shortcut->next_node);
|
||||
cursor = READ_ONCE(shortcut->next_node);
|
||||
}
|
||||
|
||||
node = assoc_array_ptr_to_node(cursor);
|
||||
|
@ -55,7 +55,7 @@ begin_node:
|
|||
*/
|
||||
has_meta = 0;
|
||||
for (; slot < ASSOC_ARRAY_FAN_OUT; slot++) {
|
||||
ptr = ACCESS_ONCE(node->slots[slot]);
|
||||
ptr = READ_ONCE(node->slots[slot]);
|
||||
has_meta |= (unsigned long)ptr;
|
||||
if (ptr && assoc_array_ptr_is_leaf(ptr)) {
|
||||
/* We need a barrier between the read of the pointer
|
||||
|
@ -89,7 +89,7 @@ continue_node:
|
|||
smp_read_barrier_depends();
|
||||
|
||||
for (; slot < ASSOC_ARRAY_FAN_OUT; slot++) {
|
||||
ptr = ACCESS_ONCE(node->slots[slot]);
|
||||
ptr = READ_ONCE(node->slots[slot]);
|
||||
if (assoc_array_ptr_is_meta(ptr)) {
|
||||
cursor = ptr;
|
||||
goto begin_node;
|
||||
|
@ -98,7 +98,7 @@ continue_node:
|
|||
|
||||
finished_node:
|
||||
/* Move up to the parent (may need to skip back over a shortcut) */
|
||||
parent = ACCESS_ONCE(node->back_pointer);
|
||||
parent = READ_ONCE(node->back_pointer);
|
||||
slot = node->parent_slot;
|
||||
if (parent == stop)
|
||||
return 0;
|
||||
|
@ -107,7 +107,7 @@ finished_node:
|
|||
shortcut = assoc_array_ptr_to_shortcut(parent);
|
||||
smp_read_barrier_depends();
|
||||
cursor = parent;
|
||||
parent = ACCESS_ONCE(shortcut->back_pointer);
|
||||
parent = READ_ONCE(shortcut->back_pointer);
|
||||
slot = shortcut->parent_slot;
|
||||
if (parent == stop)
|
||||
return 0;
|
||||
|
@ -147,7 +147,7 @@ int assoc_array_iterate(const struct assoc_array *array,
|
|||
void *iterator_data),
|
||||
void *iterator_data)
|
||||
{
|
||||
struct assoc_array_ptr *root = ACCESS_ONCE(array->root);
|
||||
struct assoc_array_ptr *root = READ_ONCE(array->root);
|
||||
|
||||
if (!root)
|
||||
return 0;
|
||||
|
@ -194,7 +194,7 @@ assoc_array_walk(const struct assoc_array *array,
|
|||
|
||||
pr_devel("-->%s()\n", __func__);
|
||||
|
||||
cursor = ACCESS_ONCE(array->root);
|
||||
cursor = READ_ONCE(array->root);
|
||||
if (!cursor)
|
||||
return assoc_array_walk_tree_empty;
|
||||
|
||||
|
@ -220,7 +220,7 @@ consider_node:
|
|||
|
||||
slot = segments >> (level & ASSOC_ARRAY_KEY_CHUNK_MASK);
|
||||
slot &= ASSOC_ARRAY_FAN_MASK;
|
||||
ptr = ACCESS_ONCE(node->slots[slot]);
|
||||
ptr = READ_ONCE(node->slots[slot]);
|
||||
|
||||
pr_devel("consider slot %x [ix=%d type=%lu]\n",
|
||||
slot, level, (unsigned long)ptr & 3);
|
||||
|
@ -294,7 +294,7 @@ follow_shortcut:
|
|||
} while (sc_level < shortcut->skip_to_level);
|
||||
|
||||
/* The shortcut matches the leaf's index to this point. */
|
||||
cursor = ACCESS_ONCE(shortcut->next_node);
|
||||
cursor = READ_ONCE(shortcut->next_node);
|
||||
if (((level ^ sc_level) & ~ASSOC_ARRAY_KEY_CHUNK_MASK) != 0) {
|
||||
level = sc_level;
|
||||
goto jumped;
|
||||
|
@ -337,7 +337,7 @@ void *assoc_array_find(const struct assoc_array *array,
|
|||
* the terminal node.
|
||||
*/
|
||||
for (slot = 0; slot < ASSOC_ARRAY_FAN_OUT; slot++) {
|
||||
ptr = ACCESS_ONCE(node->slots[slot]);
|
||||
ptr = READ_ONCE(node->slots[slot]);
|
||||
if (ptr && assoc_array_ptr_is_leaf(ptr)) {
|
||||
/* We need a barrier between the read of the pointer
|
||||
* and dereferencing the pointer - but only if we are
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue