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


Groups > linux.kernel > #1605140 > unrolled thread

[PATCH] doc: Update the comparisons rule in rcu_dereference.txt

Started byMichalis Kokologiannakis <mixaskok@gmail.com>
First post2017-03-20 22:40 +0100
Last post2017-03-21 19:20 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] doc: Update the comparisons rule in rcu_dereference.txt Michalis Kokologiannakis <mixaskok@gmail.com> - 2017-03-20 22:40 +0100
    Re: [PATCH] doc: Update the comparisons rule in rcu_dereference.txt "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-03-21 19:20 +0100

#1605140 — [PATCH] doc: Update the comparisons rule in rcu_dereference.txt

FromMichalis Kokologiannakis <mixaskok@gmail.com>
Date2017-03-20 22:40 +0100
Subject[PATCH] doc: Update the comparisons rule in rcu_dereference.txt
Message-ID<tndbY-2bk-27@gated-at.bofh.it>
When an RCU-protected pointer is fetched but never dereferenced
rcu_access_pointer() should be used in place of rcu_dereference().
This commit explicitly records this very fact in Documentation/
RCU/rcu_dereference.txt, in order to prevent the usage of
rcu_dereference() in comparisons.

Signed-off-by: Michalis Kokologiannakis <mixaskok@gmail.com>
---
 Documentation/RCU/rcu_dereference.txt | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/Documentation/RCU/rcu_dereference.txt b/Documentation/RCU/rcu_dereference.txt
index c0bf244..b2a613f 100644
--- a/Documentation/RCU/rcu_dereference.txt
+++ b/Documentation/RCU/rcu_dereference.txt
@@ -138,6 +138,15 @@ o	Be very careful about comparing pointers obtained from
 		This sort of comparison occurs frequently when scanning
 		RCU-protected circular linked lists.
 
+		Note that if checks for being within an RCU read-side
+		critical section are not required and the pointer is never
+		dereferenced, rcu_access_pointer() should be used in place
+		of rcu_dereference(). The rcu_access_pointer() primitive
+		does not require an enclosing read-side critical section,
+		and also omits the smp_read_barrier_depends() included in
+		rcu_dereference(), which in turn should provide a small
+		performance gain in some CPUs (e.g., the DEC Alpha).
+
 	o	The comparison is against a pointer that references memory
 		that was initialized "a long time ago."  The reason
 		this is safe is that even if misordering occurs, the
-- 
2.1.4

[toc] | [next] | [standalone]


#1605874

From"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Date2017-03-21 19:20 +0100
Message-ID<tnwxX-6Zw-7@gated-at.bofh.it>
In reply to#1605140
On Mon, Mar 20, 2017 at 10:38:35PM +0100, Michalis Kokologiannakis wrote:
> When an RCU-protected pointer is fetched but never dereferenced
> rcu_access_pointer() should be used in place of rcu_dereference().
> This commit explicitly records this very fact in Documentation/
> RCU/rcu_dereference.txt, in order to prevent the usage of
> rcu_dereference() in comparisons.
> 
> Signed-off-by: Michalis Kokologiannakis <mixaskok@gmail.com>

Queued for review, thank you!

							Thanx, Paul

> ---
>  Documentation/RCU/rcu_dereference.txt | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/Documentation/RCU/rcu_dereference.txt b/Documentation/RCU/rcu_dereference.txt
> index c0bf244..b2a613f 100644
> --- a/Documentation/RCU/rcu_dereference.txt
> +++ b/Documentation/RCU/rcu_dereference.txt
> @@ -138,6 +138,15 @@ o	Be very careful about comparing pointers obtained from
>  		This sort of comparison occurs frequently when scanning
>  		RCU-protected circular linked lists.
> 
> +		Note that if checks for being within an RCU read-side
> +		critical section are not required and the pointer is never
> +		dereferenced, rcu_access_pointer() should be used in place
> +		of rcu_dereference(). The rcu_access_pointer() primitive
> +		does not require an enclosing read-side critical section,
> +		and also omits the smp_read_barrier_depends() included in
> +		rcu_dereference(), which in turn should provide a small
> +		performance gain in some CPUs (e.g., the DEC Alpha).
> +
>  	o	The comparison is against a pointer that references memory
>  		that was initialized "a long time ago."  The reason
>  		this is safe is that even if misordering occurs, the
> -- 
> 2.1.4
> 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web