[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <53767e33e58a54cc73e6d49e09275a76d33abc92.camel@infradead.org>
Date: Thu, 10 Feb 2022 14:11:11 +0000
From: David Woodhouse <dwmw2@...radead.org>
To: Joao Martins <joao.m.martins@...cle.com>
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 Thu, 2022-02-10 at 12:17 +0000, Joao Martins wrote:
> On 2/8/22 12:36, David Woodhouse wrote:
> > > + 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.
>
It does block.
https://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=xen/common/sched/core.c;hb=RELEASE-4.14.4#l1385
It sets the _VPF_blocked bit in the vCPU's pause_flags, then the
raise_softirq(SCHEDULE_SOFTIRQ) causes it to deschedule this vCPU when
it gets back to the return-to-guest path. It's not Linux, so you don't
see a schedule() call :)
It'll remain blocked until either an (unmasked) event channel or HVM
IRQ is asserted, or one of the masked event channels listed in the poll
list is raised.
Which is why I tried to tie it into the kvm_vcpu_halt() code path when
I updated the patch.
Download attachment "smime.p7s" of type "application/pkcs7-signature" (5965 bytes)
Powered by blists - more mailing lists