public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Low <jason.low2@hp.com>
To: Waiman Long <waiman.long@hp.com>
Cc: Davidlohr Bueso <davidlohr@hp.com>,
	mingo@kernel.org, peterz@infradead.org, tglx@linutronix.de,
	akpm@linux-foundation.org, tim.c.chen@linux.intel.com,
	paulmck@linux.vnet.ibm.com, hpa@zytor.com, aswin@hp.com,
	linux-kernel@vger.kernel.org, jason.low2@hp.com
Subject: Re: [PATCH v3] mutex: Documentation rewrite
Date: Tue, 27 May 2014 10:33:24 -0700	[thread overview]
Message-ID: <1401212004.2199.11.camel@j-VirtualBox> (raw)
In-Reply-To: <5384B735.6050501@hp.com>

On Tue, 2014-05-27 at 12:03 -0400, Waiman Long wrote:
> On 05/23/2014 11:16 AM, Davidlohr Bueso wrote:
> > From: Davidlohr Bueso<davidlohr@hp.com>
> >
> >
> > +
> > +(ii) midpath: aka optimistic spinning, tries to spin for acquisition
> > +     when there are no pending waiters and the lock owner is currently
> 
> That is not true. The spinning code doesn't check if there is any 
> pending waiters. So some tasks can be spinning while the others are 
> sleeping. The only checks are: 1) The lock owner is running; 2) there is 
> no other higher-priority ready-to-run task (need_resched).

Ah yes, I have noticed a similar comment in the mutex.c file and I have
been holding on to a patch which corrects the comments in that file. 

Below was the patch for your reference:

-----
Subject: [PATCH 2/3] mutex: Correct documention on mutex optimistic spinning

The mutex optimistic spinning documentation states that we spin for
acquisition when we find that there are no pending waiters. However,
in actuality, whether or not there are waiters for the mutex doesn't
determine if we will spin for it.

This patch removes that statement and also adds a comment which
mentions that we spin for the mutex while we don't need to reschedule.

Signed-off-by: Jason Low <jason.low2@hp.com>
---
 kernel/locking/mutex.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c
index 0925968..fc55f72 100644
--- a/kernel/locking/mutex.c
+++ b/kernel/locking/mutex.c
@@ -389,12 +389,10 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
 	/*
 	 * Optimistic spinning.
 	 *
-	 * We try to spin for acquisition when we find that there are no
-	 * pending waiters and the lock owner is currently running on a
-	 * (different) CPU.
-	 *
-	 * The rationale is that if the lock owner is running, it is likely to
-	 * release the lock soon.
+	 * We try to spin for acquisition when we find that the lock owner
+	 * is currently running on a (different) CPU and while we don't
+	 * need to reschedule. The rationale is that if the lock owner is
+	 * running, it is likely to release the lock soon.
 	 *
 	 * Since this needs the lock owner, and this mutex implementation
 	 * doesn't track the owner atomically in the lock field, we need to
-- 
1.7.1




  reply	other threads:[~2014-05-27 17:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-21 17:41 [RFC PATCH] mutex: Documentation rewrite Davidlohr Bueso
2014-05-21 19:02 ` Tim Chen
2014-05-21 19:52   ` Davidlohr Bueso
2014-05-21 21:16 ` Jason Low
2014-05-21 22:42   ` Davidlohr Bueso
2014-05-22 16:41 ` [PATCH v2] " Davidlohr Bueso
2014-05-22 17:09   ` Randy Dunlap
2014-05-23 15:16 ` [PATCH v3] " Davidlohr Bueso
2014-05-27 16:03   ` Waiman Long
2014-05-27 17:33     ` Jason Low [this message]
2014-05-29  4:36 ` [PATCH v4] " Davidlohr Bueso
2014-06-05 14:40   ` [tip:locking/core] locking/mutexes: Documentation update/rewrite tip-bot for 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=1401212004.2199.11.camel@j-VirtualBox \
    --to=jason.low2@hp.com \
    --cc=akpm@linux-foundation.org \
    --cc=aswin@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=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=tim.c.chen@linux.intel.com \
    --cc=waiman.long@hp.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