All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Vrabel <david.vrabel@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: xen-devel@lists.xenproject.org, Keir Fraser <keir@xen.org>,
	Ian Campbell <ian.campbell@citrix.com>, Tim Deegan <tim@xen.org>
Subject: Re: [RFC PATCHv1] Prototype ticket locks
Date: Tue, 3 Feb 2015 15:01:07 +0000	[thread overview]
Message-ID: <54D0E2B3.1020405@citrix.com> (raw)
In-Reply-To: <54D0E167020000780005C6BD@mail.emea.novell.com>

On 03/02/15 13:55, Jan Beulich wrote:
>>>> On 03.02.15 at 12:50, <david.vrabel@citrix.com> wrote:
>> Use ticket locks for spin locks instead of the current byte locks.
>> Ticket locks are fair.  This is an important property for hypervisor
>> locks.
> 
> Isn't Linux moving to queue locks? Shouldn't we skip the intermediate
> step then, not the least because they will cause problems when Xen
> itself gets run virtualized?

ticket locks are trivial.  Why should we wait for the mythical future
where someone implements queue locks to actually get better/fairer locks?

I also don't think the characteristics of queue locks vs ticket locks
are really any different in a virtualized guest.  FWIW, the latest Linux
queue lock series falls back to byte locks in non-PV-aware guests.

>> This prototype has the following limitations:
>> - Only 256 CPUs (8 bit tickets).
>> - Broken lock profiling.
>> - x86 only.
>>
>> Note that spin_lock_irq() and spin_lock_irqsave() now spin with irqs
>> disabled (previously, they would spin with irqs enabled if possible).
>> This is required to prevent deadlocks when the irq handler tries to
>> take the same lock with a higher ticket.
> 
> That's another pretty undesirable property (albeit it's not a strict
> implication of using ticket locks - one can make them work with
> interrupts getting properly re-enabled while spinning).

I've seen too many Linux deadlocks caused be re-enabling irqs while
spinning to consider this a good idea.  The ticket stealing stuff that
Suse kernels do doesn't play nice with rw locks or certain hand rolled
synchronization code (in short, if the interrupt spins on something
other than a ticket lock it breaks).

> It was for these reasons that so far I didn't go and steal Linux'es
> ticket lock implementation (and I think you should at least mention
> the origin in the description).

Sorry, this was taken (almost as-is) from Nick Piggin's Linux
implementation.

David

  reply	other threads:[~2015-02-03 15:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-03 11:50 [RFC PATCHv1] Prototype ticket locks David Vrabel
2015-02-03 13:55 ` Jan Beulich
2015-02-03 15:01   ` David Vrabel [this message]
2015-02-03 16:03     ` Jan Beulich

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=54D0E2B3.1020405@citrix.com \
    --to=david.vrabel@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=ian.campbell@citrix.com \
    --cc=keir@xen.org \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xenproject.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.