From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: David Miller <davem@davemloft.net>
Cc: eric.dumazet@gmail.com, shemminger@vyatta.com,
mchan@broadcom.com, linux-kernel@vger.kernel.org
Subject: Re: RCU: how to suppress warnings from rcu_assign_pointer?
Date: Sun, 31 Jul 2011 22:23:42 -0700 [thread overview]
Message-ID: <20110801052342.GD2307@linux.vnet.ibm.com> (raw)
In-Reply-To: <20110730.201609.2157787571393748046.davem@davemloft.net>
On Sat, Jul 30, 2011 at 08:16:09PM -0700, David Miller wrote:
> From: Eric Dumazet <eric.dumazet@gmail.com>
> Date: Sat, 30 Jul 2011 14:17:05 +0200
>
> > Le vendredi 29 juillet 2011 à 10:50 -0700, Stephen Hemminger a écrit :
> >> Gcc now generates warnings from rcu_assign_pointer when passed the
> >> address of something for example:
> >> rcu_assign_pointer(dev_queue->qdisc, &noop_qdisc);
> >> This warning is harmless and should be surpressed but there maybe
> >> other cases where we want that Gcc warning.
> >>
> >> I tried various combinations of in rcu_assign_pointer macro
> >> #pragma GCC diagnostic push
> >> #pragma GCC diagnostic ignored "-Wlogical-op"
> >> ...
> >> #pragma GCC diagnostic pop
> >> but macro's and pragma's don't nest with the correct scope for
> >> this.
> >>
> >> Maybe some one with more Gcc foo and time to waste could take
> >> a crack at it.
> >
> > I would just remove the test from rcu_assign_pointer().
> >
> > We now have RCU_INIT_POINTER() for places we dont want/afford the
> > smp_wmb()
>
> Agreed:
>
> Acked-by: David S. Miller <davem@davemloft.net>
Very good!!! Many thanks to the three of you!
I have queued this, adding Eric's Signed-off-by. Eric, could you please
reply either giving me explicit permission to do this or telling me that
you would rather that I apply under my own Signed-off-by? (I would guess
that the former is OK with you, but I really do need to know for sure.)
Please see below for the current state of this commit in my on-laptop
-rcu tree.
I have also added a second commit upgrading comment headers to call out
exactly when RCU_INIT_POINTER() may be used.
Thanx, Paul
------------------------------------------------------------------------
rcu: Make rcu_assign_pointer() unconditionally insert a memory barrier
Recent changes to gcc give warning messages on rcu_assign_pointers()'s
checks that allow it to determine when it is OK to omit the memory
barrier. Stephen Hemminger tried a number of gcc tricks to silence
this warning, but #pragmas and CPP macros do not work together in the
way that would be required to make this work.
However, we now have RCU_INIT_POINTER(), which already omits this
memory barrier, and which therefore may be used when assigning NULL to
an RCU-protected pointer that is accessible to readers. This commit
therefore makes rcu_assign_pointer() unconditionally emit the memory
barrier.
Reported-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index ea80396..b2e5fe8 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -443,9 +443,7 @@ extern int rcu_my_thread_group_empty(void);
})
#define __rcu_assign_pointer(p, v, space) \
({ \
- if (!__builtin_constant_p(v) || \
- ((v) != NULL)) \
- smp_wmb(); \
+ smp_wmb(); \
(p) = (typeof(*v) __force space *)(v); \
})
next prev parent reply other threads:[~2011-08-01 5:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20110728142723.77a2c308@nehalam.ftrdhcpuser.net>
[not found] ` <20110728214442.GV2403@linux.vnet.ibm.com>
[not found] ` <20110728145510.0ec0db01@nehalam.ftrdhcpuser.net>
[not found] ` <20110729003843.GA2373@linux.vnet.ibm.com>
2011-07-29 17:50 ` RCU: how to suppress warnings from rcu_assign_pointer? Stephen Hemminger
2011-07-30 12:17 ` Eric Dumazet
2011-07-31 3:16 ` David Miller
2011-08-01 5:23 ` Paul E. McKenney [this message]
2011-08-01 8:47 ` Eric Dumazet
2011-08-01 16:19 ` [PATCH] rcu: convert uses of rcu_assign_pointer(x, NULL) to RCU_INIT_POINTER Stephen Hemminger
2011-08-02 5:44 ` David Miller
2011-08-02 10:32 ` Paul E. McKenney
2011-08-02 11:29 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110801052342.GD2307@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mchan@broadcom.com \
--cc=shemminger@vyatta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox