From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BFE5C433EF for ; Wed, 13 Apr 2022 13:47:11 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 8D6A24B229; Wed, 13 Apr 2022 09:47:10 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@kernel.org Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TudP2nXyb2kM; Wed, 13 Apr 2022 09:47:09 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 6BEB24A49C; Wed, 13 Apr 2022 09:47:09 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 5B4E84A49C for ; Wed, 13 Apr 2022 09:47:07 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lwMDoJai1H8K for ; Wed, 13 Apr 2022 09:47:02 -0400 (EDT) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 065DB49F5B for ; Wed, 13 Apr 2022 09:47:01 -0400 (EDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6A5ED61943; Wed, 13 Apr 2022 13:47:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF745C385A4; Wed, 13 Apr 2022 13:46:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649857619; bh=i5lzFw1ROF9MKAhGCUIV1AVoLWPXDmxI34tlOG7J/Hc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=iAvDaW4ezj9xNtK7nEzufIn55UE2kDKlKfE4KO2a1VzzayMvagY/j+o8p10DXwdYb EOHyr/ULZI2DhjO6bYaZfD+U/o0dwLjrM5TB9JysMhuxjavq37x2YBplHLOZYATRbt Mn2HvsmxwuDAjFbYyxpFQ6eS6u51HL+hq29cqlAKyrhbxSqV1oAjnEz3pp/N53Iq6R jCZWmZiaCwbopygkQ4LUe+lwK4y+uW4+s6LOcHox9ylSC6IeIsXsD/UOFp7W51byIY EDt76YLrZbILfYikWIYcGwtjySal1fTD81brAvMTne9Coq4gbKYnCLjFdcYOYydX5J oey3jK9niEbVA== Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nedKj-0043Ek-5h; Wed, 13 Apr 2022 14:46:57 +0100 Date: Wed, 13 Apr 2022 14:46:56 +0100 Message-ID: <87a6cpayen.wl-maz@kernel.org> From: Marc Zyngier To: Joey Gouly Subject: Re: [PATCH 06/10] KVM: arm64: Offer early resume for non-blocking WFxT instructions In-Reply-To: <20220413113726.GA35565@e124191.cambridge.arm.com> References: <20220412131303.504690-1-maz@kernel.org> <20220412131303.504690-7-maz@kernel.org> <20220413113726.GA35565@e124191.cambridge.arm.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: joey.gouly@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, james.morse@arm.com, suzuki.poulose@arm.com, alexandru.elisei@arm.com, kernel-team@android.com, nd@arm.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Cc: kernel-team@android.com, kvm@vger.kernel.org, Catalin Marinas , nd@arm.com, Will Deacon , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On Wed, 13 Apr 2022 12:37:26 +0100, Joey Gouly 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 > > --- > > 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. _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm