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

Documentation: circular-buffers: use READ_ONCE()

While the {READ,WRITE}_ONCE() macros should be used in preference to
ACCESS_ONCE(), the circular buffer documentation uses the latter
exclusively.

To point people in the right direction, and as a step towards the
eventual removal of ACCESS_ONCE(), update the documentation to use
READ_ONCE(), as ACCESS_ONCE() is only used in a reader context in the
circular buffer documentation.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: David Howells <dhowells@redhat.com>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>

authored by

Mark Rutland and committed by
Jonathan Corbet
01e46442 47f42122

+2 -2
+2 -2
Documentation/circular-buffers.txt
··· 161 161 162 162 unsigned long head = buffer->head; 163 163 /* The spin_unlock() and next spin_lock() provide needed ordering. */ 164 - unsigned long tail = ACCESS_ONCE(buffer->tail); 164 + unsigned long tail = READ_ONCE(buffer->tail); 165 165 166 166 if (CIRC_SPACE(head, tail, buffer->size) >= 1) { 167 167 /* insert one item into the buffer */ ··· 222 222 the new item, and then it shall make sure the CPU has finished reading the item 223 223 before it writes the new tail pointer, which will erase the item. 224 224 225 - Note the use of ACCESS_ONCE() and smp_load_acquire() to read the 225 + Note the use of READ_ONCE() and smp_load_acquire() to read the 226 226 opposition index. This prevents the compiler from discarding and 227 227 reloading its cached value - which some compilers will do across 228 228 smp_read_barrier_depends(). This isn't strictly needed if you can