From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Avi Kivity <avi@redhat.com>
Cc: Don Zickus <dzickus@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
"H. Peter Anvin" <hpa@zytor.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Ingo Molnar <mingo@elte.hu>,
the arch/x86 maintainers <x86@kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Nick Piggin <npiggin@kernel.dk>,
Marcelo Tosatti <mtosatti@redhat.com>, KVM <kvm@vger.kernel.org>,
Andi Kleen <andi@firstfloor.org>,
Xen Devel <xen-devel@lists.xensource.com>,
Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: Re: [PATCH 08/13] xen/pvticketlock: disable interrupts while blocking
Date: Thu, 08 Sep 2011 10:29:08 -0700 [thread overview]
Message-ID: <4E68FB64.9080308@goop.org> (raw)
In-Reply-To: <4E6873FE.3040603@redhat.com>
On 09/08/2011 12:51 AM, Avi Kivity wrote:
> On 09/07/2011 10:09 PM, Jeremy Fitzhardinge wrote:
>> On 09/07/2011 10:41 AM, Avi Kivity wrote:
>> >> Hm, I'm interested to know what you're thinking in more detail.
>> Can you
>> >> leave an NMI pending before you block in the same way you can with
>> >> "sti;halt" with normal interrupts?
>> >
>> >
>> > Nope. But you can do
>> >
>> > if (regs->rip in critical section)
>> > regs->rip = after_halt;
>> >
>> > and effectively emulate it. The critical section is something like
>> >
>> > critical_section_start:
>> > if (woken_up)
>> > goto critical_section_end;
>> > hlt
>> > critical_section_end:
>>
>> Hm. It's a pity you have to deliver an actual interrupt to implement
>> the kick though.
>
> I don't think it's that expensive, especially compared to the
> double-context-switch and vmexit of the spinner going to sleep. On
> AMD we do have to take an extra vmexit (on IRET) though.
Fair enough - so if the vcpu blocks itself, it ends up being rescheduled
in the NMI handler, which then returns to the lock slowpath. And if its
a normal hlt, then you can also take interrupts if they're enabled while
spinning.
And if you get nested NMIs (since you can get multiple spurious kicks,
or from other NMI sources), then one NMI will get latched and any others
will get dropped?
> Well we could have a specialized sleep/wakeup hypercall pair like Xen,
> but I'd like to avoid it if at all possible.
Yeah, that's something that just falls out of the existing event channel
machinery, so it isn't something that I specifically added. But it does
mean that you simply end up with a hypercall returning on kick, with no
real complexities.
J
WARNING: multiple messages have this Message-ID (diff)
From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Avi Kivity <avi@redhat.com>
Cc: Don Zickus <dzickus@redhat.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
Nick Piggin <npiggin@kernel.dk>, KVM <kvm@vger.kernel.org>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
Peter Zijlstra <peterz@infradead.org>,
the arch/x86 maintainers <x86@kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Andi Kleen <andi@firstfloor.org>,
Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>,
"H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@elte.hu>,
Linus Torvalds <torvalds@linux-foundation.org>,
Xen Devel <xen-devel@lists.xensource.com>
Subject: Re: [PATCH 08/13] xen/pvticketlock: disable interrupts while blocking
Date: Thu, 08 Sep 2011 10:29:08 -0700 [thread overview]
Message-ID: <4E68FB64.9080308@goop.org> (raw)
In-Reply-To: <4E6873FE.3040603@redhat.com>
On 09/08/2011 12:51 AM, Avi Kivity wrote:
> On 09/07/2011 10:09 PM, Jeremy Fitzhardinge wrote:
>> On 09/07/2011 10:41 AM, Avi Kivity wrote:
>> >> Hm, I'm interested to know what you're thinking in more detail.
>> Can you
>> >> leave an NMI pending before you block in the same way you can with
>> >> "sti;halt" with normal interrupts?
>> >
>> >
>> > Nope. But you can do
>> >
>> > if (regs->rip in critical section)
>> > regs->rip = after_halt;
>> >
>> > and effectively emulate it. The critical section is something like
>> >
>> > critical_section_start:
>> > if (woken_up)
>> > goto critical_section_end;
>> > hlt
>> > critical_section_end:
>>
>> Hm. It's a pity you have to deliver an actual interrupt to implement
>> the kick though.
>
> I don't think it's that expensive, especially compared to the
> double-context-switch and vmexit of the spinner going to sleep. On
> AMD we do have to take an extra vmexit (on IRET) though.
Fair enough - so if the vcpu blocks itself, it ends up being rescheduled
in the NMI handler, which then returns to the lock slowpath. And if its
a normal hlt, then you can also take interrupts if they're enabled while
spinning.
And if you get nested NMIs (since you can get multiple spurious kicks,
or from other NMI sources), then one NMI will get latched and any others
will get dropped?
> Well we could have a specialized sleep/wakeup hypercall pair like Xen,
> but I'd like to avoid it if at all possible.
Yeah, that's something that just falls out of the existing event channel
machinery, so it isn't something that I specifically added. But it does
mean that you simply end up with a hypercall returning on kick, with no
real complexities.
J
next prev parent reply other threads:[~2011-09-08 23:27 UTC|newest]
Thread overview: 86+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-02 0:54 [PATCH 00/13] [PATCH RFC] Paravirtualized ticketlocks Jeremy Fitzhardinge
2011-09-02 0:54 ` [PATCH 01/13] x86/spinlocks: replace pv spinlocks with pv ticketlocks Jeremy Fitzhardinge
2011-09-02 0:54 ` [PATCH 02/13] x86/ticketlock: collapse a layer of functions Jeremy Fitzhardinge
2011-09-02 0:54 ` Jeremy Fitzhardinge
2011-09-02 0:54 ` [PATCH 03/13] xen/pvticketlock: Xen implementation for PV ticket locks Jeremy Fitzhardinge
2011-09-02 0:54 ` Jeremy Fitzhardinge
2011-09-02 0:54 ` [PATCH 04/13] x86/pvticketlock: use callee-save for lock_spinning Jeremy Fitzhardinge
2011-09-02 0:54 ` [PATCH 05/13] x86/ticketlocks: when paravirtualizing ticket locks, increment by 2 Jeremy Fitzhardinge
2011-09-02 0:54 ` [PATCH 06/13] x86/ticketlock: add slowpath logic Jeremy Fitzhardinge
2011-09-02 18:46 ` Eric Northup
2011-09-02 19:32 ` Jeremy Fitzhardinge
2011-09-02 0:55 ` [PATCH 07/13] x86/ticketlocks: tidy up __ticket_unlock_kick() Jeremy Fitzhardinge
2011-09-02 0:55 ` [PATCH 08/13] xen/pvticketlock: disable interrupts while blocking Jeremy Fitzhardinge
2011-09-02 14:47 ` Peter Zijlstra
2011-09-02 19:29 ` Jeremy Fitzhardinge
2011-09-02 19:29 ` Jeremy Fitzhardinge
2011-09-02 20:47 ` Peter Zijlstra
2011-09-02 20:47 ` Peter Zijlstra
2011-09-02 21:50 ` Jeremy Fitzhardinge
2011-09-02 22:37 ` Peter Zijlstra
2011-09-02 22:37 ` Peter Zijlstra
2011-09-02 23:14 ` Andi Kleen
2011-09-05 11:52 ` Stefano Stabellini
2011-09-05 12:05 ` Avi Kivity
2011-09-06 15:14 ` Don Zickus
2011-09-06 18:07 ` Jeremy Fitzhardinge
2011-09-06 18:27 ` Don Zickus
2011-09-06 18:50 ` Jeremy Fitzhardinge
2011-09-06 18:50 ` Jeremy Fitzhardinge
2011-09-07 4:13 ` Avi Kivity
2011-09-07 13:44 ` Don Zickus
2011-09-07 13:44 ` Don Zickus
2011-09-07 15:11 ` Avi Kivity
2011-09-07 15:11 ` Avi Kivity
2011-09-07 15:56 ` Don Zickus
2011-09-07 15:56 ` Don Zickus
2011-09-07 16:25 ` Avi Kivity
2011-09-07 16:52 ` Don Zickus
2011-09-07 17:09 ` Avi Kivity
2011-09-07 17:17 ` Jeremy Fitzhardinge
2011-09-07 17:41 ` Avi Kivity
2011-09-07 19:09 ` Jeremy Fitzhardinge
2011-09-08 7:51 ` Avi Kivity
2011-09-08 17:29 ` Jeremy Fitzhardinge [this message]
2011-09-08 17:29 ` Jeremy Fitzhardinge
2011-09-11 9:59 ` Avi Kivity
2011-09-11 9:59 ` Avi Kivity
2011-09-07 17:21 ` Don Zickus
2011-09-07 17:21 ` Don Zickus
2011-09-07 17:41 ` Avi Kivity
2011-09-13 18:40 ` Don Zickus
2011-09-13 19:03 ` Andi Kleen
2011-09-13 19:21 ` Don Zickus
2011-09-13 19:21 ` Don Zickus
2011-09-13 19:58 ` Andi Kleen
2011-09-13 20:53 ` Don Zickus
2011-09-13 21:04 ` Andi Kleen
2011-09-14 7:00 ` Avi Kivity
2011-09-14 12:49 ` Don Zickus
2011-09-14 12:49 ` Don Zickus
2011-09-14 14:49 ` Andi Kleen
2011-09-14 15:01 ` Avi Kivity
2011-09-14 17:28 ` Andi Kleen
2011-09-14 17:28 ` Andi Kleen
2011-09-14 19:26 ` Avi Kivity
2011-09-14 19:34 ` Andi Kleen
2011-09-14 19:34 ` Andi Kleen
2011-09-14 19:56 ` Avi Kivity
2011-09-13 19:27 ` Don Zickus
2011-09-02 0:55 ` [PATCH 09/13] x86/pvticketlocks: we only need to kick if there's waiters Jeremy Fitzhardinge
2011-09-02 0:55 ` [PATCH 10/13] xen/pvticket: allow interrupts to be enabled while blocking Jeremy Fitzhardinge
2011-09-02 14:48 ` Peter Zijlstra
2011-09-02 19:30 ` Jeremy Fitzhardinge
2011-09-02 0:55 ` [PATCH 11/13] x86/ticketlock: only do kick after doing unlock Jeremy Fitzhardinge
2011-09-02 14:49 ` Peter Zijlstra
2011-09-02 19:34 ` Jeremy Fitzhardinge
2011-09-02 19:34 ` Jeremy Fitzhardinge
2011-09-02 0:55 ` [PATCH 12/13] x86/pvticketlock: make sure unlock_kick pvop call is inlined Jeremy Fitzhardinge
2011-09-02 0:55 ` [PATCH 13/13] x86/pvticketlock: use __ticket_t for pvop args Jeremy Fitzhardinge
2011-09-02 11:22 ` [PATCH 00/13] [PATCH RFC] Paravirtualized ticketlocks Stefano Stabellini
2011-09-02 11:22 ` Stefano Stabellini
2011-09-06 19:33 ` Jeremy Fitzhardinge
2011-09-02 15:38 ` Linus Torvalds
2011-09-02 20:07 ` Jeremy Fitzhardinge
2011-09-02 20:27 ` Linus Torvalds
2011-09-02 21:42 ` Jeremy Fitzhardinge
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=4E68FB64.9080308@goop.org \
--to=jeremy@goop.org \
--cc=andi@firstfloor.org \
--cc=avi@redhat.com \
--cc=dzickus@redhat.com \
--cc=hpa@zytor.com \
--cc=jeremy.fitzhardinge@citrix.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mtosatti@redhat.com \
--cc=npiggin@kernel.dk \
--cc=peterz@infradead.org \
--cc=stefano.stabellini@eu.citrix.com \
--cc=torvalds@linux-foundation.org \
--cc=x86@kernel.org \
--cc=xen-devel@lists.xensource.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 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.