netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Randy Dunlap <randy.dunlap@oracle.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,
	akpm@linux-foundation.org
Subject: Re: [PATCH 2/2] add rcu_assign_index() if ever needed
Date: Thu, 14 Feb 2008 10:48:42 -0800	[thread overview]
Message-ID: <20080214184842.GD8910@linux.vnet.ibm.com> (raw)
In-Reply-To: <20080214092427.960d1f67.randy.dunlap@oracle.com>

On Thu, Feb 14, 2008 at 09:24:27AM -0800, Randy Dunlap wrote:
> On Wed, 13 Feb 2008 14:05:15 -0800 Paul E. McKenney wrote:
> 
> > Hello again!
> > 
> > This is a speculative patch that as far as I can tell is not yet required.
> > If anyone applies RCU to a data structure allocated out of an array, using
> > array indexes in place of pointers to link the array elements together,
> > then the rcu_assign_index() function in this patch will be needed to
> > assign a given element's array index to the RCU-traversed index.  The
> > implementation is exactly that of the old rcu_assign_pointer(), so is
> > extremely well tested.
> > 
> > The existing rcu_assign_pointer() will emit a compiler warning in cases
> > where rcu_assign_index() is required.
> > 
> > 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-rap/include/linux/rcupdate.h linux-2.6.24-rai/include/linux/rcupdate.h
> > --- linux-2.6.24-rap/include/linux/rcupdate.h	2008-02-13 13:36:47.000000000 -0800
> > +++ linux-2.6.24-rai/include/linux/rcupdate.h	2008-02-13 10:55:40.000000000 -0800
> > @@ -286,6 +286,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
> > + * read-side critical sections.  Returns the value assigned.
> > + *
> > + * Inserts memory barriers on architectures that require them
> > + * (pretty much all of them other than x86), and also prevents
> > + * the compiler from reordering the code that initializes the
> > + * structure after the index assignment.  More importantly, this
> > + * call documents which indexes will be dereferenced by RCU read-side
> > + * code.
> > + */
> 
> s/a index/index/
> 
> Along with Gautham's typo fix, you could also make this be passable
> kernel-doc notation.  :)

Guess I should do the same for rcu_assign_pointer() and probably several
others as well...  Good catch!!!

							Thanx, Paul

> See Documentation/kernel-doc-nano-HOWTO.txt for details.
> 
> Summary:
> The function (or macro) name and short description must be on one line.
> This is followed by the parameters, then a "blank" (actually " *") line,
> then any (longer) description, notes, etc.  So basically:
> 
> /**
>  * rcu_assign_index - assign (publicize) index of a newly initialized array element
>  * @p: description of @p
>  * @v: description of @v
>  *
>  * This function assigns (publicizes) the index of a newly
>  * initialized array element that will be dereferenced by RCU
>  * read-side critical sections.  Returns the value assigned.
>  *
>  * Inserts memory barriers on architectures that require them
>  * (pretty much all of them other than x86), and also prevents
>  * the compiler from reordering the code that initializes the
>  * structure after the index assignment.  More importantly, this
>  * call documents which indexes will be dereferenced by RCU read-side
>  * code.
>  */
> 
> 
> > +
> > +#define rcu_assign_index(p, v)	({ \
> > +					smp_wmb(); \
> > +					(p) = (v); \
> > +				})
> > +
> > +/**
> >   * synchronize_sched - block until all CPUs have exited any non-preemptive
> >   * kernel code sequences.
> >   *
> 
> ---
> ~Randy

  reply	other threads:[~2008-02-14 18:49 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 [this message]
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
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=20080214184842.GD8910@linux.vnet.ibm.com \
    --to=paulmck@linux.vnet.ibm.com \
    --cc=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=randy.dunlap@oracle.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).