| Subject | Re: [PATCH RFC 15/39] KVM: x86/xen: handle PV spinlocks slowpath | From | David Woodhouse <> | Date | Tue, 08 Feb 2022 12:36:33 +0000 |
| |
On Wed, 2019-02-20 at 20:15 +0000, Joao Martins wrote: > From: Boris Ostrovsky <boris.ostrovsky@oracle.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@oracle.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? 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?
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?
+ if (!wait_pending_event(vcpu, sched_poll.nr_ports, ports)) { + vcpu->arch.mp_state = KVM_MP_STATE_HALTED; + kvm_vcpu_halt(vcpu);
[unhandled content-type:application/pkcs7-signature] |