linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Davidlohr Bueso <dave@stgolabs.net>
Cc: tglx@linutronix.de, mingo@kernel.org, longman@redhat.com,
	linux-kernel@vger.kernel.org, Davidlohr Bueso <dbues@suse.de>
Subject: Re: [PATCH 2/2] rtmutex: Reduce top-waiter blocking on a lock
Date: Fri, 20 Apr 2018 17:50:28 +0200	[thread overview]
Message-ID: <20180420155028.GO4064@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20180410162750.8290-2-dave@stgolabs.net>

On Tue, Apr 10, 2018 at 09:27:50AM -0700, Davidlohr Bueso wrote:
> By applying well known spin-on-lock-owner techniques, we can avoid the
> blocking overhead during the process of when the task is trying to take
> the rtmutex. The idea is that as long as the owner is running, there is a
> fair chance it'll release the lock soon, and thus a task trying to acquire
> the rtmutex will better off spinning instead of blocking immediately after
> the fastpath. This is similar to what we use for other locks, borrowed
> from -rt. The main difference (due to the obvious realtime constraints)
> is that top-waiter spinning must account for any new higher priority waiter,
> and therefore cannot steal the lock and avoid any pi-dance. As such there
> will be at most only one spinner waiter upon contended lock.
> 
> Conditions to stop spinning and block are simple:
> 
> (1) Upon need_resched()
> (2) Current lock owner blocks
> (3) The top-waiter has changed while spinning.
> 
> The unlock side remains unchanged as wake_up_process can safely deal with
> calls where the task is not actually blocked (TASK_NORMAL). As such, there
> is only unnecessary overhead dealing with the wake_q, but this allows us not
> to miss any wakeups between the spinning step and the unlocking side.
> 
> Passes running the pi_stress program with increasing thread-group counts.

Is this similar to what we have in RT (which, IIRC, has an optimistic
spinning implementation as well)?

ISTR there being some contention over the exact semantics of (3) many
years ago. IIRC the question was if an equal priority task was allowed
to steal; because lock stealing can lead to fairness issues. One would
expect two FIFO-50 tasks to be 'fair' wrt lock acquisition and not
starve one another.

Therefore I think we only allowed higher prio tasks to steal and kept
FIFO order for equal prioty tasks.

  parent reply	other threads:[~2018-04-20 15:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-10 16:27 [PATCH 1/2] locking/rtmutex: Delete save_state member of struct rt_mutex Davidlohr Bueso
2018-04-10 16:27 ` [PATCH 2/2] rtmutex: Reduce top-waiter blocking on a lock Davidlohr Bueso
2018-04-11 12:51   ` kbuild test robot
2018-04-17 16:52     ` Davidlohr Bueso
2018-04-20 15:50   ` Peter Zijlstra [this message]
2018-04-20 16:48     ` Mike Galbraith
2018-04-22  2:39       ` Davidlohr Bueso
2018-06-17 17:26   ` Davidlohr Bueso
2018-04-20 15:25 ` [PATCH 3/2] rtmutex: Use waiter debug init,free magic numbers 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=20180420155028.GO4064@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=dave@stgolabs.net \
    --cc=dbues@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mingo@kernel.org \
    --cc=tglx@linutronix.de \
    /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;
as well as URLs for NNTP newsgroup(s).