LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: paulmck@linux.vnet.ibm.com
Cc: linux-kernel@vger.kernel.org, shemminger@vyatta.com,
davem@davemloft.net, netdev@vger.kernel.org, dipankar@in.ibm.com,
ego@in.ibm.com, herbert@gondor.apana.org.au
Subject: Re: [PATCH 1/2] remove rcu_assign_pointer(NULL) penalty with type/macro safety
Date: Fri, 15 Feb 2008 16:40:24 -0800 [thread overview]
Message-ID: <20080215164024.7fd356fa.akpm@linux-foundation.org> (raw)
In-Reply-To: <20080213220024.GA30729@linux.vnet.ibm.com>
On Wed, 13 Feb 2008 14:00:24 -0800
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com> wrote:
> Hello!
>
> This is an updated version of the patch posted last November:
>
> http://archives.free.net.ph/message/20071201.003721.cd6ff17c.en.html
>
> This new version permits arguments with side effects, for example:
>
> rcu_assign_pointer(global_p, p++);
>
> and also verifies that the arguments are pointers, while still avoiding
> the unnecessary memory barrier when assigning NULL to a pointer.
> This memory-barrier avoidance means that rcu_assign_pointer() is now only
> permitted for pointers (not array indexes), and so this version emits a
> compiler warning if the first argument is not a pointer. I built a "make
> allyesconfig" version on an x86 system, and received no such warnings.
> If RCU is ever applied to array indexes, then the second patch in this
> series should be applied, and the resulting rcu_assign_index() be used.
>
> Given the rather surprising history of subtlely broken implementations of
> rcu_assign_pointer(), I took the precaution of generating a full set of
> test cases and verified that memory barriers and compiler warnings were
> emitted when required. I guess it is the simple things that get you...
>
> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> ---
>
> rcupdate.h | 16 ++++++++++++----
> 1 file changed, 12 insertions(+), 4 deletions(-)
>
> diff -urpNa -X dontdiff linux-2.6.24/include/linux/rcupdate.h linux-2.6.24-rap/include/linux/rcupdate.h
> --- linux-2.6.24/include/linux/rcupdate.h 2008-01-24 14:58:37.000000000 -0800
> +++ linux-2.6.24-rap/include/linux/rcupdate.h 2008-02-13 13:36:47.000000000 -0800
> @@ -270,12 +270,20 @@ extern struct lockdep_map rcu_lock_map;
> * structure after the pointer assignment. More importantly, this
> * call documents which pointers will be dereferenced by RCU read-side
> * code.
> + *
> + * Throws a compiler warning for non-pointer arguments.
> + *
> + * Does not insert a memory barrier for a NULL pointer.
> */
>
> -#define rcu_assign_pointer(p, v) ({ \
> - smp_wmb(); \
> - (p) = (v); \
> - })
> +#define rcu_assign_pointer(p, v) \
> + ({ \
> + typeof(*p) *_________p1 = (v); \
> + \
> + if (!__builtin_constant_p(v) || (_________p1 != NULL)) \
> + smp_wmb(); \
> + (p) = _________p1; \
> + })
>
umm...
net/netfilter/core.c: In function 'nf_register_afinfo':
net/netfilter/core.c:39: warning: initialization discards qualifiers from pointer target type
net/netfilter/nf_log.c: In function 'nf_log_register':
net/netfilter/nf_log.c:37: warning: initialization discards qualifiers from pointer target type
net/netfilter/nf_queue.c: In function 'nf_register_queue_handler':
net/netfilter/nf_queue.c:38: warning: initialization discards qualifiers from pointer target type
next prev parent reply other threads:[~2008-02-16 0:41 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-13 22:00 [PATCH 1/2] remove rcu_assign_pointer(NULL) penalty with type/macro safety Paul E. McKenney
2008-02-13 22:05 ` [PATCH 2/2] add rcu_assign_index() if ever needed Paul E. McKenney
2008-02-14 3:32 ` Gautham R Shenoy
2008-02-14 3:41 ` Andrew Morton
2008-02-14 17:08 ` Paul E. McKenney
2008-02-14 17:24 ` Randy Dunlap
2008-02-14 18:48 ` Paul E. McKenney
2008-02-13 22:11 ` [PATCH 1/2] remove rcu_assign_pointer(NULL) penalty with type/macro safety Andrew Morton
[not found] ` <20080213143537.1b806790@extreme>
2008-02-13 22:41 ` Paul E. McKenney
[not found] ` <20080213144233.05e860cb@extreme>
2008-02-13 23:37 ` Paul E. McKenney
2008-02-13 23:51 ` Stephen Hemminger
2008-02-14 0:14 ` Paul E. McKenney
2008-02-14 0:27 ` Stephen Hemminger
2008-02-14 0:42 ` Paul E. McKenney
2008-02-14 0:53 ` Stephen Hemminger
2008-02-14 1:34 ` Paul E. McKenney
2008-02-14 1:37 ` Stephen Hemminger
2008-02-13 23:52 ` Andrew Morton
2008-02-13 23:55 ` Stephen Hemminger
2008-02-13 23:57 ` David Miller
2008-02-14 0:09 ` Andrew Morton
2008-02-16 0:40 ` Andrew Morton [this message]
2008-02-16 1:23 ` Paul E. McKenney
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=20080215164024.7fd356fa.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=dipankar@in.ibm.com \
--cc=ego@in.ibm.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=paulmck@linux.vnet.ibm.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;
as well as URLs for NNTP newsgroup(s).