All of lore.kernel.org
 help / color / mirror / Atom feed
From: Waiman Long <waiman.long@hpe.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>, <linux-kernel@vger.kernel.org>,
	"Linus Torvalds" <torvalds@linux-foundation.org>,
	Ding Tianhong <dingtianhong@huawei.com>,
	Jason Low <jason.low2@hpe.com>,
	Davidlohr Bueso <dave@stgolabs.net>,
	"Paul E. McKenney" <paulmck@us.ibm.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Will Deacon <Will.Deacon@arm.com>,
	Tim Chen <tim.c.chen@linux.intel.com>,
	Imre Deak <imre.deak@intel.com>
Subject: Re: [PATCH v4 3/3] locking/mutex: Ensure forward progress of waiter-spinner
Date: Tue, 9 Aug 2016 14:00:00 -0400	[thread overview]
Message-ID: <57AA1A20.4090904@hpe.com> (raw)
In-Reply-To: <20160808173716.GZ6862@twins.programming.kicks-ass.net>

On 08/08/2016 01:37 PM, Peter Zijlstra wrote:
> On Mon, Jul 18, 2016 at 04:39:26PM -0400, Waiman Long wrote:
>> As both an optimistic spinner and a waiter-spinner (a woken task from
>> the wait queue spinning) can be spinning on the lock at the same time,
>> we cannot ensure forward progress for the waiter-spinner. Therefore,
>> it is possible for the waiter-spinner to be starved of getting the
>> lock, though not likely.
> Right; yet your previous two changelogs/comments implied otherwise.
>
>> This patch adds a flag to indicate that a waiter-spinner is
>> spinning and hence has priority over the acquisition of the lock. A
>> waiter-spinner sets this flag while spinning. An optimistic spinner
>> will check this flag and yield if set. This essentially makes the
>> waiter-spinner jump to the head of the optimistic spinning queue to
>> acquire the lock.
>>
>> There will be no increase in size for the mutex structure for 64-bit
>> architectures. For 32-bit architectures, there will be a size increase
>> of 4 bytes.
> Alternative might be to use the LSB of mutex::owner, but that's going to
> be somewhat icky too.

I was thinking about doing that. However, the owner field is used in 
quite a number of places. It may be a bit risky to change all of them.

> I'm not sure the 32bit platforms are going to be excited about growing
> struct mutex...

Or we can make this a 64-bit architecture specific change if the 
increase in mutex size is a real concern. Actually, we don't need to use 
a list_head structure for wait_list. It can be just a pointer to 
mutex_waiter that has the list_head structure. This can save a pointer 
from the structure.

Cheers,
Longman

  reply	other threads:[~2016-08-09 18:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-18 20:39 [PATCH v4 0/3] locking/mutex: Enable optimistic spinning of lock waiter Waiman Long
2016-07-18 20:39 ` [PATCH v4 1/3] locking/mutex: Add waiter parameter to mutex_optimistic_spin() Waiman Long
2016-08-08 17:26   ` Peter Zijlstra
2016-08-09 17:36     ` Waiman Long
2016-07-18 20:39 ` [PATCH v4 2/3] locking/mutex: Enable optimistic spinning of woken task in wait queue Waiman Long
2016-08-08 17:29   ` Peter Zijlstra
2016-08-09 17:49     ` Waiman Long
2016-07-18 20:39 ` [PATCH v4 3/3] locking/mutex: Ensure forward progress of waiter-spinner Waiman Long
2016-08-08 17:37   ` Peter Zijlstra
2016-08-09 18:00     ` Waiman Long [this message]
2016-08-10  9:29       ` Peter Zijlstra
2016-08-10 17:51         ` Waiman Long

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=57AA1A20.4090904@hpe.com \
    --to=waiman.long@hpe.com \
    --cc=Will.Deacon@arm.com \
    --cc=dave@stgolabs.net \
    --cc=dingtianhong@huawei.com \
    --cc=imre.deak@intel.com \
    --cc=jason.low2@hpe.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=paulmck@us.ibm.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=tim.c.chen@linux.intel.com \
    --cc=torvalds@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.