From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: sequence lock in Linux
Date: Fri, 11 Jun 2010 16:46:48 -0400 [thread overview]
Message-ID: <20100611204648.GA20360@Krystal> (raw)
In-Reply-To: <20100611200700.GG2394@linux.vnet.ibm.com>
* Paul E. McKenney (paulmck@linux.vnet.ibm.com) wrote:
> On Fri, Jun 11, 2010 at 03:40:16PM -0400, Mathieu Desnoyers wrote:
> > Hi Paul,
> >
> > (CCing lkml)
> >
> > Is it just me, or the following code:
> >
> > static __always_inline unsigned read_seqbegin(const seqlock_t *sl)
> > {
> > unsigned ret;
> >
> > repeat:
> > ret = sl->sequence;
> > smp_rmb();
> > if (unlikely(ret & 1)) {
> > cpu_relax();
> > goto repeat;
> > }
> >
> > return ret;
> > }
> >
> > could use a ACCESS_ONCE() around the sl->sequence read ? I'm concerned about the
> > compiler generating code that reads the sequence number chunkwise.
> >
> > The same apply to all other reads of the sequence number in seqlock.h (including
> > the retry code).
> >
> > Thoughts ?
>
> Doesn't gcc guarantee that accesses to aligned basic types that fit into
> a machine word are loaded and stored in one shot? Now, gcc might choose
> to load twice (or to merge loads) due to things like register pressure,
> but given that ->sequence is an int, gcc should not be accessing it
> (say) bytewise on any platform supporting 32-bit accesses.
>
> Or am I suffering from wishful thinking here?
Hopefully not. I might be the one suffering from extreme compiler distrust here.
;-)
Mathieu
>
> Thanx, Paul
--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
next prev parent reply other threads:[~2010-06-11 20:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-11 19:40 sequence lock in Linux Mathieu Desnoyers
2010-06-11 20:07 ` Paul E. McKenney
2010-06-11 20:46 ` Mathieu Desnoyers [this message]
2010-06-11 20:07 ` Linus Torvalds
2010-06-11 20:36 ` Paul E. McKenney
2010-06-11 21:06 ` H. Peter Anvin
2010-06-11 21:36 ` Paul E. McKenney
2010-06-11 21:38 ` H. Peter Anvin
2010-06-11 22:04 ` Paul E. McKenney
2010-06-11 22:41 ` H. Peter Anvin
2010-06-11 21:09 ` Mathieu Desnoyers
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=20100611204648.GA20360@Krystal \
--to=mathieu.desnoyers@efficios.com \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@linux.vnet.ibm.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