mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Will Deacon <will.deacon@arm.com>
To: Davidlohr Bueso <davidlohr@hp.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"rkuo@codeaurora.org" <rkuo@codeaurora.org>,
	"arnd@arndb.de" <arnd@arndb.de>,
	"paulus@samba.org" <paulus@samba.org>
Subject: Re: [PATCH 1/2] asm-generic: rwsem: ensure sem->cnt is only accessed via atomic_long_*
Date: Thu, 27 Feb 2014 18:53:07 +0000	[thread overview]
Message-ID: <20140227185306.GN30003@mudshark.cambridge.arm.com> (raw)
In-Reply-To: <1393478904.3884.6.camel@buesod1.americas.hpqcorp.net>

On Thu, Feb 27, 2014 at 05:28:24AM +0000, Davidlohr Bueso wrote:
> On Fri, 2014-02-21 at 17:22 +0000, Will Deacon wrote:
> > The asm-generic rwsem implementation directly acceses sem->cnt when
> > performing a __down_read_trylock operation. Whilst this is probably safe
> > on all architectures, we should stick to the atomic_long_* API and use
> > atomic_long_read instead.
> > 
> > Signed-off-by: Will Deacon <will.deacon@arm.com>
> > ---
> >  include/asm-generic/rwsem.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/include/asm-generic/rwsem.h b/include/asm-generic/rwsem.h
> > index bb1e2cdeb9bf..75af612f54f8 100644
> > --- a/include/asm-generic/rwsem.h
> > +++ b/include/asm-generic/rwsem.h
> > @@ -41,7 +41,7 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
> >  {
> >  	long tmp;
> >  
> > -	while ((tmp = sem->count) >= 0) {
> > +	while ((tmp = atomic_long_read((atomic_long_t *)&sem->count)) >= 0) {
> 
> That's pretty ugly, how about having infinite look and just do the tmp
> assign separately from the conditional?
> 
> It also looks like a cpu_relax() could help here between iterations.

Sure, I can do these in a separate patch (this patch is just a simple fix).

> Reviewed-by: Davidlohr Bueso <davidlohr@hp.com>

Thanks,

Will

  reply	other threads:[~2014-02-27 18:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-21 17:22 Will Deacon
2014-02-21 17:22 ` [PATCH 2/2] asm-generic: rwsem: de-PPCify rwsem.h Will Deacon
2014-02-26 18:05   ` rkuo
2014-02-27  5:28 ` [PATCH 1/2] asm-generic: rwsem: ensure sem->cnt is only accessed via atomic_long_* Davidlohr Bueso
2014-02-27 18:53   ` Will Deacon [this message]
2014-02-28 12:13   ` Will Deacon
2014-02-28 12:50     ` Peter Hurley
2014-02-28 15:41       ` Will Deacon

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=20140227185306.GN30003@mudshark.cambridge.arm.com \
    --to=will.deacon@arm.com \
    --cc=arnd@arndb.de \
    --cc=davidlohr@hp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulus@samba.org \
    --cc=rkuo@codeaurora.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

Powered by JetHome