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


Groups > linux.kernel > #1436981 > unrolled thread

[PATCH net-next 22/24] rcu: Suppress sparse warnings for rcu_dereference_raw()

Started byDavid Howells <dhowells@redhat.com>
First post2016-07-05 15:20 +0200
Last post2016-07-05 23:40 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH net-next 22/24] rcu: Suppress sparse warnings for  rcu_dereference_raw() David Howells <dhowells@redhat.com> - 2016-07-05 15:20 +0200
    Re: [PATCH net-next 22/24] rcu: Suppress sparse warnings for  rcu_dereference_raw() "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-07-05 23:40 +0200

#1436981 — [PATCH net-next 22/24] rcu: Suppress sparse warnings for rcu_dereference_raw()

FromDavid Howells <dhowells@redhat.com>
Date2016-07-05 15:20 +0200
Subject[PATCH net-next 22/24] rcu: Suppress sparse warnings for rcu_dereference_raw()
Message-ID<rRyqC-3hh-21@gated-at.bofh.it>
From: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

Data structures that are used both with and without RCU protection
are difficult to write in a sparse-clean manner.  If you mark the
relevant pointers with __rcu, sparse will complain about all non-RCU
uses, but if you don't mark those pointers, sparse will complain about
all RCU uses.

This commit therefore suppresses sparse warnings for rcu_dereference_raw(),
allowing mixed-protection data structures to avoid these warnings.

Reported-by: David Howells <dhowells@redhat.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: David Howells <dhowells@redhat.com>
---

 include/linux/rcupdate.h |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 5f1533e3d032..85830e6c797b 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -611,6 +611,12 @@ static inline void rcu_preempt_sleep_check(void)
 	rcu_dereference_sparse(p, space); \
 	((typeof(*p) __force __kernel *)(p)); \
 })
+#define rcu_dereference_raw(p) \
+({ \
+	/* Dependency order vs. p above. */ \
+	typeof(p) ________p1 = lockless_dereference(p); \
+	((typeof(*p) __force __kernel *)(________p1)); \
+})
 
 /**
  * RCU_INITIALIZER() - statically initialize an RCU-protected global variable
@@ -729,8 +735,6 @@ static inline void rcu_preempt_sleep_check(void)
 	__rcu_dereference_check((p), (c) || rcu_read_lock_sched_held(), \
 				__rcu)
 
-#define rcu_dereference_raw(p) rcu_dereference_check(p, 1) /*@@@ needed? @@@*/
-
 /*
  * The tracing infrastructure traces RCU (we want that), but unfortunately
  * some of the RCU checks causes tracing to lock up the system.

[toc] | [next] | [standalone]


#1437299

From"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Date2016-07-05 23:40 +0200
Message-ID<rRGet-8pR-5@gated-at.bofh.it>
In reply to#1436981
On Tue, Jul 05, 2016 at 02:14:49PM +0100, David Howells wrote:
> From: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> 
> Data structures that are used both with and without RCU protection
> are difficult to write in a sparse-clean manner.  If you mark the
> relevant pointers with __rcu, sparse will complain about all non-RCU
> uses, but if you don't mark those pointers, sparse will complain about
> all RCU uses.
> 
> This commit therefore suppresses sparse warnings for rcu_dereference_raw(),
> allowing mixed-protection data structures to avoid these warnings.
> 
> Reported-by: David Howells <dhowells@redhat.com>
> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> Signed-off-by: David Howells <dhowells@redhat.com>

This would normally be my cue to give an Acked-by to an RCU patch, but
it already has my Signed-off-by.  So this is just to confirm that I agree
that keeping this patch with the other patches that depend on it is the
right thing to do.  ;-)

							Thanx, Paul

> ---
> 
>  include/linux/rcupdate.h |    8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
> index 5f1533e3d032..85830e6c797b 100644
> --- a/include/linux/rcupdate.h
> +++ b/include/linux/rcupdate.h
> @@ -611,6 +611,12 @@ static inline void rcu_preempt_sleep_check(void)
>  	rcu_dereference_sparse(p, space); \
>  	((typeof(*p) __force __kernel *)(p)); \
>  })
> +#define rcu_dereference_raw(p) \
> +({ \
> +	/* Dependency order vs. p above. */ \
> +	typeof(p) ________p1 = lockless_dereference(p); \
> +	((typeof(*p) __force __kernel *)(________p1)); \
> +})
> 
>  /**
>   * RCU_INITIALIZER() - statically initialize an RCU-protected global variable
> @@ -729,8 +735,6 @@ static inline void rcu_preempt_sleep_check(void)
>  	__rcu_dereference_check((p), (c) || rcu_read_lock_sched_held(), \
>  				__rcu)
> 
> -#define rcu_dereference_raw(p) rcu_dereference_check(p, 1) /*@@@ needed? @@@*/
> -
>  /*
>   * The tracing infrastructure traces RCU (we want that), but unfortunately
>   * some of the RCU checks causes tracing to lock up the system.
> 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web