[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <97b17522-ec57-3ad5-b9cf-037835158e48@oracle.com>
Date: Thu, 10 Feb 2022 12:17:12 +0000
From: Joao Martins <joao.m.martins@...cle.com>
To: David Woodhouse <dwmw2@...radead.org>
Cc: Ankur Arora <ankur.a.arora@...cle.com>,
Boris Ostrovsky <boris.ostrovsky@...cle.com>,
Paolo Bonzini <pbonzini@...hat.com>,
Radim Krčmář <rkrcmar@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
"H. Peter Anvin" <hpa@...or.com>, x86@...nel.org,
kvm@...r.kernel.org, metikaya@...zon.co.uk,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH RFC 15/39] KVM: x86/xen: handle PV spinlocks slowpath
On 2/8/22 12:36, David Woodhouse wrote:
> On Wed, 2019-02-20 at 20:15 +0000, Joao Martins wrote:
>> From: Boris Ostrovsky <boris.ostrovsky@...cle.com>
>>
>> Add support for SCHEDOP_poll hypercall.
>>
>> This implementation is optimized for polling for a single channel, which
>> is what Linux does. Polling for multiple channels is not especially
>> efficient (and has not been tested).
>>
>> PV spinlocks slow path uses this hypercall, and explicitly crash if it's
>> not supported.
>>
>> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@...cle.com>
>> ---
>
> ...
>
>> +static void kvm_xen_check_poller(struct kvm_vcpu *vcpu, int port)
>> +{
>> + struct kvm_vcpu_xen *vcpu_xen = vcpu_to_xen_vcpu(vcpu);
>> +
>> + if ((vcpu_xen->poll_evtchn == port ||
>> + vcpu_xen->poll_evtchn == -1) &&
>> + test_and_clear_bit(vcpu->vcpu_id, vcpu->kvm->arch.xen.poll_mask))
>> + wake_up(&vcpu_xen->sched_waitq);
>> +}
>
> ...
>
>> + if (sched_poll.nr_ports == 1)
>> + vcpu_xen->poll_evtchn = port;
>> + else
>> + vcpu_xen->poll_evtchn = -1;
>> +
>> + if (!wait_pending_event(vcpu, sched_poll.nr_ports, ports))
>> + wait_event_interruptible_timeout(
>> + vcpu_xen->sched_waitq,
>> + wait_pending_event(vcpu, sched_poll.nr_ports, ports),
>> + sched_poll.timeout ?: KTIME_MAX);
>
> Hm, this doesn't wake on other interrupts, does it?
Hmm, I don't think so? This was specifically polling on event channels,
not sleeping or blocking.
> I think it should.
> Shouldn't it basically be like HLT, with an additional wakeup when the
> listed ports are triggered even when they're masked?
>
I am actually not sure.
Quickly glancing at the xen source, this hypercall doesn't appear to really
block the vcpu, but rather just looking if the evtchn ports are pending and
if a timeout is is specified it sets up a timer. And ofc, wake any evtchn
pollers. But it doesn't appear to actually block the VCPU. It should be
IIRC, the functional equivalent of KVM_HC_VAPIC_POLL_IRQ but for event
channels.
> At https://git.infradead.org/users/dwmw2/linux.git/commitdiff/ddfbdf1af
> I've tried to make it use kvm_vcpu_halt(), and kvm_xen_check_poller()
> sets KVM_REQ_UNBLOCK when an event is delivered to a monitored port.
>
> I haven't quite got it to work yet, but does it seem like a sane
> approach?
>
Joao
Powered by blists - more mailing lists