LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Jarek Poplawski <jarkao2@gmail.com>
To: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: David Miller <davem@davemloft.net>,
	shemminger@vyatta.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fib_trie: rcu_assign_pointer warning fix
Date: Tue, 12 Feb 2008 20:32:18 +0100	[thread overview]
Message-ID: <20080212193218.GA2803@ami.dom.local> (raw)
In-Reply-To: <20080212160729.GA9157@linux.vnet.ibm.com>

On Tue, Feb 12, 2008 at 08:07:29AM -0800, Paul E. McKenney wrote:
...
> "All programmers are blind, especially me."

Hmm... I got it my way: you - superheroes - sometimes seem to be just
like us - common people... (Probably early in the morning, before
dressing your funny costumes?) 

> You are right, Jarek.  I ran this through gcc, and the following
> comes close:
> 
> #define rcu_assign_pointer(p, v) \
> 	({ \
> 		if (!__builtin_constant_p(v) || (v)) \
> 			smp_wmb(); \
> 		(p) = (v); \
> 	})
> 
> But I am concerned about the following case:
> 
> 	rcu_assign_pointer(global_index, 0);
> 
> 	. . .
> 
> 	x = global_array[rcu_dereference(global_index)];
> 
> Since arrays have a zero-th element, we would really want a memory
> barrier in this case.

It seems the above version of this macro uses the barrier for 0, but
if I miss something, or for these other: documenting reasons, then of
course you are right.

> 
> So how about leaving the index-unfriendly version of rcu_assign_pointer()
> and adding an rcu_assign_index() as follows?
> 
> 							Thanx, Paul
> 
> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> ---
> 
>  rcupdate.h |   18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff -urpNa -X dontdiff linux-2.6.24/include/linux/rcupdate.h linux-2.6.24-rai/include/linux/rcupdate.h
> --- linux-2.6.24/include/linux/rcupdate.h	2008-01-24 14:58:37.000000000 -0800
> +++ linux-2.6.24-rai/include/linux/rcupdate.h	2008-02-12 08:04:59.000000000 -0800
> @@ -278,6 +278,24 @@ extern struct lockdep_map rcu_lock_map;
>  					})
>  
>  /**
> + * rcu_assign_index - assign (publicize) a index of a newly
> + * initialized array elementg that will be dereferenced by RCU

---------------------------^
 + * initialized array element that will be dereferenced by RCU

Regards,
Jarek P.

  reply	other threads:[~2008-02-12 19:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20080211165954.2f1b3a9b@extreme>
2008-02-12  1:16 ` David Miller
2008-02-12  8:57   ` Jarek Poplawski
2008-02-12 16:07     ` Paul E. McKenney
2008-02-12 19:32       ` Jarek Poplawski [this message]
2008-02-12 19:46         ` Jarek Poplawski
2008-02-13 22:55           ` Paul E. McKenney
     [not found] ` <20080212012741.GD29254@linux.vnet.ibm.com>
2008-02-12  5:15   ` David Miller
2008-02-12  1:18 Stephen Hemminger

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=20080212193218.GA2803@ami.dom.local \
    --to=jarkao2@gmail.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=shemminger@vyatta.com \
    --subject='Re: [PATCH] fib_trie: rcu_assign_pointer warning fix' \
    /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

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