public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Low <jason.low2@hp.com>
To: Davidlohr Bueso <davidlohr@hp.com>
Cc: mingo@kernel.org, peterz@infradead.org, tglx@linutronix.de,
	akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
	paulmck@linux.vnet.ibm.com, tim.c.chen@linux.intel.com,
	peter@hurleysoftware.com, riel@redhat.com, hpa@zytor.com,
	walken@google.com, Waiman.Long@hp.com, aswin@hp.com,
	scott.norton@hp.com, chegu_vinod@hp.com
Subject: Re: [RFC PATCH 3/3] locking/mutex: Optimize mutex trylock slowpath
Date: Wed, 04 Jun 2014 20:08:59 -0700	[thread overview]
Message-ID: <1401937739.6680.5.camel@j-VirtualBox> (raw)
In-Reply-To: <1401930628.13877.29.camel@buesod1.americas.hpqcorp.net>

On Wed, 2014-06-04 at 18:10 -0700, Davidlohr Bueso wrote:
> On Wed, 2014-06-04 at 14:47 -0700, Jason Low wrote:
> > On Wed, 2014-06-04 at 13:28 -0700, Davidlohr Bueso wrote:
> > > On Wed, 2014-06-04 at 12:08 -0700, Jason Low wrote:
> > > > In __mutex_trylock_slowpath(), we acquire the wait_lock spinlock,
> > > > xchg() lock->count with -1, then set lock->count back to 0 if there
> > > > are no waiters, and return true if the prev lock count was 1.
> > > > 
> > > > However, if we the mutex is already locked, then there may not be
> > >              ^^ leave that out.
> > > 
> > > > much point in attempting the above operations. 
> > > 
> > > Isn't this redundant? I mean, if we enter the slowpath its because
> > > __mutex_fastpath_trylock() already failed so we already know that the
> > > lock is taken.
> > 
> > This function is really just used as an alternative method of trylock
> > for !__HAVE_ARCH_CMPXCHG.  In that case, the fastpath can call directly
> > into the slowpath function, without checking for if the lock is taken.
> 
> Ah, ok I hadn't seen that we do this in 32bit x86 and was wondering why
> the heck we fallback on a slowpath for something like trylock, which
> should return right away no matter what. I'd suggest explicitly
> mentioning this in the changelog. Otherwise makes sense now.

Yup, I was also initially wondering why we have a slowpath for trylock,
which prompted me to take a look into this function. I'll add some more
information about this to the changelog.

Thanks,
Jason


  reply	other threads:[~2014-06-05  3:09 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-04 19:08 [RFC PATCH 0/3] locking/mutex: Modifications to mutex Jason Low
2014-06-04 19:08 ` [RFC PATCH 1/3] locking/mutex: Try to acquire mutex only if it is unlocked Jason Low
2014-06-04 19:43   ` Peter Zijlstra
2014-06-04 20:57     ` Davidlohr Bueso
2014-06-04 20:58       ` Davidlohr Bueso
2014-06-09 17:38         ` Jason Low
2014-06-11 21:00           ` Long, Wai Man
2014-06-11 21:48             ` Jason Low
2014-06-12  1:25               ` Long, Wai Man
2014-06-04 21:53       ` Jason Low
2014-06-04 21:26     ` Jason Low
2014-06-04 21:54       ` Thomas Gleixner
2014-06-04 22:13         ` Jason Low
2014-06-05  3:24       ` Waiman Long
2014-06-05 19:21         ` Jason Low
2014-06-04 19:08 ` [RFC PATCH 2/3] locking/mutex: Correct documentation on mutex optimistic spinning Jason Low
2014-06-04 20:11   ` Davidlohr Bueso
2014-06-04 20:30     ` Jason Low
2014-06-04 19:08 ` [RFC PATCH 3/3] locking/mutex: Optimize mutex trylock slowpath Jason Low
2014-06-04 20:28   ` Davidlohr Bueso
2014-06-04 21:47     ` Jason Low
2014-06-05  1:10       ` Davidlohr Bueso
2014-06-05  3:08         ` Jason Low [this message]
2014-06-04 20:13 ` [RFC PATCH 0/3] locking/mutex: Modifications to mutex Davidlohr Bueso

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=1401937739.6680.5.camel@j-VirtualBox \
    --to=jason.low2@hp.com \
    --cc=Waiman.Long@hp.com \
    --cc=akpm@linux-foundation.org \
    --cc=aswin@hp.com \
    --cc=chegu_vinod@hp.com \
    --cc=davidlohr@hp.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peter@hurleysoftware.com \
    --cc=peterz@infradead.org \
    --cc=riel@redhat.com \
    --cc=scott.norton@hp.com \
    --cc=tglx@linutronix.de \
    --cc=tim.c.chen@linux.intel.com \
    --cc=walken@google.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