Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1523386 > unrolled thread

[PATCH] Documentation: circular-buffers: use READ_ONCE()

Started byMark Rutland <mark.rutland@arm.com>
First post2016-11-16 12:20 +0100
Last post2016-11-17 00:20 +0100
Articles 4 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] Documentation: circular-buffers: use READ_ONCE() Mark Rutland <mark.rutland@arm.com> - 2016-11-16 12:20 +0100
    Re: [PATCH] Documentation: circular-buffers: use READ_ONCE() David Howells <dhowells@redhat.com> - 2016-11-16 14:50 +0100
    Re: [PATCH] Documentation: circular-buffers: use READ_ONCE() "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-11-16 15:30 +0100
    Re: [PATCH] Documentation: circular-buffers: use READ_ONCE() Jonathan Corbet <corbet@lwn.net> - 2016-11-17 00:20 +0100

#1523386 — [PATCH] Documentation: circular-buffers: use READ_ONCE()

FromMark Rutland <mark.rutland@arm.com>
Date2016-11-16 12:20 +0100
Subject[PATCH] Documentation: circular-buffers: use READ_ONCE()
Message-ID<sE6pY-258-11@gated-at.bofh.it>
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>
Cc: David Howells <dhowells@redhat.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: linux-doc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 Documentation/circular-buffers.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/circular-buffers.txt b/Documentation/circular-buffers.txt
index 88951b1..4a824d2 100644
--- a/Documentation/circular-buffers.txt
+++ b/Documentation/circular-buffers.txt
@@ -161,7 +161,7 @@ The producer will look something like this:
 
 	unsigned long head = buffer->head;
 	/* The spin_unlock() and next spin_lock() provide needed ordering. */
-	unsigned long tail = ACCESS_ONCE(buffer->tail);
+	unsigned long tail = READ_ONCE(buffer->tail);
 
 	if (CIRC_SPACE(head, tail, buffer->size) >= 1) {
 		/* insert one item into the buffer */
@@ -222,7 +222,7 @@ This will instruct the CPU to make sure the index is up to date before reading
 the new item, and then it shall make sure the CPU has finished reading the item
 before it writes the new tail pointer, which will erase the item.
 
-Note the use of ACCESS_ONCE() and smp_load_acquire() to read the
+Note the use of READ_ONCE() and smp_load_acquire() to read the
 opposition index.  This prevents the compiler from discarding and
 reloading its cached value - which some compilers will do across
 smp_read_barrier_depends().  This isn't strictly needed if you can
-- 
1.9.1

[toc] | [next] | [standalone]


#1523474

FromDavid Howells <dhowells@redhat.com>
Date2016-11-16 14:50 +0100
Message-ID<sE8L7-3uw-21@gated-at.bofh.it>
In reply to#1523386
Mark Rutland <mark.rutland@arm.com> wrote:

> 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>
> Cc: Jonathan Corbet <corbet@lwn.net>
> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> Cc: linux-doc@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org

Acked-by: David Howells <dhowells@redhat.com>

[toc] | [prev] | [next] | [standalone]


#1523518

From"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Date2016-11-16 15:30 +0100
Message-ID<sE9nQ-45C-27@gated-at.bofh.it>
In reply to#1523386
On Wed, Nov 16, 2016 at 11:12:49AM +0000, Mark Rutland wrote:
> 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>
> Cc: David Howells <dhowells@redhat.com>
> Cc: Jonathan Corbet <corbet@lwn.net>
> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> Cc: linux-doc@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org

Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

> ---
>  Documentation/circular-buffers.txt | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/circular-buffers.txt b/Documentation/circular-buffers.txt
> index 88951b1..4a824d2 100644
> --- a/Documentation/circular-buffers.txt
> +++ b/Documentation/circular-buffers.txt
> @@ -161,7 +161,7 @@ The producer will look something like this:
> 
>  	unsigned long head = buffer->head;
>  	/* The spin_unlock() and next spin_lock() provide needed ordering. */
> -	unsigned long tail = ACCESS_ONCE(buffer->tail);
> +	unsigned long tail = READ_ONCE(buffer->tail);
> 
>  	if (CIRC_SPACE(head, tail, buffer->size) >= 1) {
>  		/* insert one item into the buffer */
> @@ -222,7 +222,7 @@ This will instruct the CPU to make sure the index is up to date before reading
>  the new item, and then it shall make sure the CPU has finished reading the item
>  before it writes the new tail pointer, which will erase the item.
> 
> -Note the use of ACCESS_ONCE() and smp_load_acquire() to read the
> +Note the use of READ_ONCE() and smp_load_acquire() to read the
>  opposition index.  This prevents the compiler from discarding and
>  reloading its cached value - which some compilers will do across
>  smp_read_barrier_depends().  This isn't strictly needed if you can
> -- 
> 1.9.1
> 

[toc] | [prev] | [next] | [standalone]


#1523962

FromJonathan Corbet <corbet@lwn.net>
Date2016-11-17 00:20 +0100
Message-ID<sEhEJ-Xw-1@gated-at.bofh.it>
In reply to#1523386
On Wed, 16 Nov 2016 11:12:49 +0000
Mark Rutland <mark.rutland@arm.com> wrote:

> 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.

Applied to the docs tree, thanks.

jon

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web