From: Herbert Xu <herbert@gondor.apana.org.au>
To: "Paul E. McKenney" <paulmck@us.ibm.com>
Cc: Linus Torvalds <torvalds@osdl.org>, Andrew Morton <akpm@osdl.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Suzanne Wood <suzannew@cs.pdx.edu>
Subject: Re: [LIST] Add missing rcu_dereference on first element
Date: Sat, 15 Oct 2005 12:39:18 +1000 [thread overview]
Message-ID: <20051015023918.GA22074@gondor.apana.org.au> (raw)
In-Reply-To: <20051015020324.GL1302@us.ibm.com>
On Fri, Oct 14, 2005 at 07:03:25PM -0700, Paul E. McKenney wrote:
>
> > diff --git a/include/linux/list.h b/include/linux/list.h
> > --- a/include/linux/list.h
> > +++ b/include/linux/list.h
> > @@ -442,12 +442,15 @@ static inline void list_splice_init(stru
> > * as long as the traversal is guarded by rcu_read_lock().
> > */
> > #define list_for_each_rcu(pos, head) \
> > - for (pos = (head)->next; prefetch(pos->next), pos != (head); \
> > - pos = rcu_dereference(pos->next))
> > + for (pos = (head)->next; \
> > + pos = rcu_dereference(pos), \
> > + prefetch(pos->next), pos != (head); \
> > + pos = pos->next)
>
> Why not something like the following? Seems a bit simpler to me.
>
> #define list_for_each_rcu(pos, head) \
> for (pos = rcu_dereference((head)->next); \
> prefetch(pos->next), pos != (head); \
> pos = rcu_dereference(pos->next))
In this case your version is indeed more concise. However, in most of
the other for_each macros having it in the loop conditional looks more
natural.
So in order to be consistent throughout list.h, I'd like to keep the
rcu_dereference in the loop conditional.
> > @@ -492,8 +496,10 @@ static inline void list_splice_init(stru
> > * as long as the traversal is guarded by rcu_read_lock().
> > */
> > #define list_for_each_continue_rcu(pos, head) \
> > - for ((pos) = (pos)->next; prefetch((pos)->next), (pos) != (head); \
> > - (pos) = rcu_dereference((pos)->next))
> > + for ((pos) = (pos)->next; \
> > + (pos) = rcu_dereference((pos)), \
> > + prefetch((pos)->next), (pos) != (head); \
> > + (pos) = (pos)->next)
>
> The above hurts my head -- childhood trauma due to having to use a
> FORTRAN compiler that required "I=I" at odd intervals in order to
> generate correct code... How about the following?
>
> #define list_for_each_continue_rcu(pos, head) \
> for ((pos) = (pos)->next; \
> prefetch(rcu_dereference(pos)->next), (pos) != (head); \
> (pos) = (pos)->next)
I chose to keep it out of prefetch because normally the argument to
prefetch does not have any side-effects. Even though today's prefetch
is an inline function which does respect side-effects, there is always
a possibility that someone somewhere might decide to implement prefetch
as a macro.
Besides, the expression
i = foo(i)
where foo has side-effects is pretty normal.
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
next prev parent reply other threads:[~2005-10-15 2:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-15 0:26 Herbert Xu
2005-10-15 2:03 ` Paul E. McKenney
2005-10-15 2:39 ` Herbert Xu [this message]
2005-10-15 3:22 ` Herbert Xu
2005-10-16 20:58 ` 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=20051015023918.GA22074@gondor.apana.org.au \
--to=herbert@gondor.apana.org.au \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@us.ibm.com \
--cc=suzannew@cs.pdx.edu \
--cc=torvalds@osdl.org \
/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
all inboxes | Powered by JetHome®