[PATCH 06/10] KVM: arm64: Offer early resume for non-blocking WFxT instructions
Marc Zyngier
maz at kernel.org
Wed Apr 13 06:46:56 PDT 2022
On Wed, 13 Apr 2022 12:37:26 +0100,
Joey Gouly <joey.gouly at arm.com> wrote:
>
> Hi Marc,
>
> On Tue, Apr 12, 2022 at 02:12:59PM +0100, Marc Zyngier wrote:
> > For WFxT instructions used with very small delays, it is not
> > unlikely that the deadling is already expired by the time we
>
> typo: deadline
>
> > reach the WFx handling code.
> >
> > Check for this condition as soon as possible, and return to the
> > guest immediately if we can.
> >
> > Signed-off-by: Marc Zyngier <maz at kernel.org>
> > ---
> > arch/arm64/kvm/handle_exit.c | 25 ++++++++++++++++++++++---
> > 1 file changed, 22 insertions(+), 3 deletions(-)
> >
> > diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c
> > index 4260f2cd1971..87d9a36de860 100644
> > --- a/arch/arm64/kvm/handle_exit.c
> > +++ b/arch/arm64/kvm/handle_exit.c
> > @@ -80,17 +80,34 @@ static int handle_no_fpsimd(struct kvm_vcpu *vcpu)
> > *
> > * @vcpu: the vcpu pointer
> > *
> > - * WFE: Yield the CPU and come back to this vcpu when the scheduler
> > + * WFE[T]: Yield the CPU and come back to this vcpu when the scheduler
> > * decides to.
> > * WFI: Simply call kvm_vcpu_halt(), which will halt execution of
> > * world-switches and schedule other host processes until there is an
> > * incoming IRQ or FIQ to the VM.
> > * WFIT: Same as WFI, with a timed wakeup implemented as a background timer
> > + *
> > + * WF{I,E}T can immediately return if the deadline has already expired.
> > */
> > static int kvm_handle_wfx(struct kvm_vcpu *vcpu)
> > {
> > u64 esr = kvm_vcpu_get_esr(vcpu);
> >
> > + if (esr & ESR_ELx_WFx_ISS_WFxT) {
> > + if (esr & ESR_ELx_WFx_ISS_RV) {
> > + u64 val, now;
> > +
> > + now = kvm_arm_timer_get_reg(vcpu, KVM_REG_ARM_TIMER_CNT);
> > + val = vcpu_get_reg(vcpu, kvm_vcpu_sys_get_rt(vcpu));
> > +
> > + if (now >= val)
> > + goto out;
>
> If this returns early, the trace_kvm_wfx and wfx_exit_stats below will not be
> called / updated. Is this intentional?
Good catch. No, it isn't. I'll hoist the stats/traces up to address
it.
Thanks,
M.
--
Without deviation from the norm, progress is not possible.
More information about the linux-arm-kernel
mailing list