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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0BD0EC54EBD for ; Mon, 9 Jan 2023 13:57:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OGfC/lC+yvienjZ4PxTeAvoKbKkEpf3+5hgCrGnOm2Q=; b=eIPeuodJDcyjPo 08iBFQRBadvJfK+fKk3z45lw5ZqooFUra7TSOXx3NyrcHhjsK0pCVVGepzXh3/s3HTnqdFarZ1Whf TJGeNm+ODCjeGttrlsrg1eIvYY04ZwrsF9ZAsMXQ7ahk1XpQw9vAcT9Ek2wKZ8Xt2wVVonwax7w+I Uo0R1aLrarOs+avJ7v7/Y2XisvfdRS7Wj0VKv95fm6V3V4wx1vFBbflidDJSYVSKfpV8s1ns/dsvT Sg4JgcJgGs4jf+opgChKfpdNjLaCq2xjfgXc8uO1eoy6vRQ6X/fPFZvxzhZTS/BHCLiG5OUlol1tO ITmpn/6HwrBJejYnov3w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pEscj-001kxb-1g; Mon, 09 Jan 2023 13:55:38 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pEsRk-001gpd-8O for linux-arm-kernel@lists.infradead.org; Mon, 09 Jan 2023 13:44:18 +0000 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 ams.source.kernel.org (Postfix) with ESMTPS id BA2A3B80DE4; Mon, 9 Jan 2023 13:44:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B13DC433F1; Mon, 9 Jan 2023 13:44:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673271853; bh=RRFDX5eqoSPhlwL1Ix9p5d/PVJoqD6DwTunueDGa6qE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=nEfwLa5V+K6J7dbldPOFX1cI+VMhqAJrLAmyBOcG/Yr6zRYBOudwRCA9dBZciLuGp WlSVd9sRFey59quotxvLV33ArZx8ySHh+UebHZKvAGBU96ScB4IoNC8NxbRLAWnqLy nRVFQu2ARqrdZ5ya/B+aiXdJIXIb9MShbtTX/XUpPK8VgfrIQ6VVAijn7yksKzvead a+30+qpd6cxeLqaxQmWdc5NYxhXsMg75NbZoPQQUBB+XKxlH5kPF1IUmZo6kUDOF94 5Gv4ThGppnn6LTAn5SRB04QyOhF1UjVHMLfCZgDKrkEctAxx7LEAymeKOfd4GmI4is /0aCAQl/j0U5A== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pEsRe-000Hs9-V0; Mon, 09 Jan 2023 13:44:11 +0000 Date: Mon, 09 Jan 2023 13:44:10 +0000 Message-ID: <86h6wzomad.wl-maz@kernel.org> From: Marc Zyngier To: Ganapatrao Kulkarni Cc: catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, scott@os.amperecomputing.com, Darren Hart Subject: Re: [PATCH 1/3] KVM: arm64: nv: only emulate timers that have not yet fired In-Reply-To: References: <20220824060304.21128-1-gankulkarni@os.amperecomputing.com> <20220824060304.21128-2-gankulkarni@os.amperecomputing.com> <87zgb6e54o.wl-maz@kernel.org> 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/28.2 (aarch64-unknown-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: gankulkarni@os.amperecomputing.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, scott@os.amperecomputing.com, darren@os.amperecomputing.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230109_054416_661375_28E97299 X-CRM114-Status: GOOD ( 39.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, 09 Jan 2023 12:25:13 +0000, Ganapatrao Kulkarni wrote: > > > Hi Marc, > > On 29-12-2022 06:30 pm, Marc Zyngier wrote: > > On Wed, 24 Aug 2022 07:03:02 +0100, > > Ganapatrao Kulkarni wrote: > >> > >> From: D Scott Phillips > >> > >> The timer emulation logic goes into an infinite loop when the NestedVM(L2) > >> timer is being emulated. > >> > >> While the CPU is executing in L1 context, the L2 timers are emulated using > >> host hrtimer. When the delta of cval and current time reaches zero, the > >> vtimer interrupt is fired/forwarded to L2, however the emulation function > >> in Host-Hypervisor(L0) is still restarting the hrtimer with an expiry time > >> set to now, triggering hrtimer to fire immediately and resulting in a > >> continuous trigger of hrtimer and endless looping in the timer emulation. > >> > >> Adding a fix to avoid restarting of the hrtimer if the interrupt is > >> already fired. > >> > >> Signed-off-by: D Scott Phillips > >> Signed-off-by: Ganapatrao Kulkarni > >> --- > >> arch/arm64/kvm/arch_timer.c | 3 ++- > >> 1 file changed, 2 insertions(+), 1 deletion(-) > >> > >> diff --git a/arch/arm64/kvm/arch_timer.c b/arch/arm64/kvm/arch_timer.c > >> index 2371796b1ab5..27a6ec46803a 100644 > >> --- a/arch/arm64/kvm/arch_timer.c > >> +++ b/arch/arm64/kvm/arch_timer.c > >> @@ -472,7 +472,8 @@ static void timer_emulate(struct arch_timer_context *ctx) > >> return; > >> } > >> - soft_timer_start(&ctx->hrtimer, kvm_timer_compute_delta(ctx)); > >> + if (!ctx->irq.level) > >> + soft_timer_start(&ctx->hrtimer, kvm_timer_compute_delta(ctx)); > >> } > >> static void timer_save_state(struct arch_timer_context *ctx) > > > > I think this is a regression introduced by bee038a67487 ("KVM: > > arm/arm64: Rework the timer code to use a timer_map"), and you can see > > it because the comment in this function doesn't make much sense > > anymore. > > OK, check was removed while rework in bee038a67487. > > > > Does the following work for you, mostly restoring the original code? > > Below diff too works and avoids the unnecessary soft timer restarts > with zero delta. > > > > Thanks, > > > > M. > > > > diff --git a/arch/arm64/kvm/arch_timer.c b/arch/arm64/kvm/arch_timer.c > > index ad2a5df88810..4945c5b96f05 100644 > > --- a/arch/arm64/kvm/arch_timer.c > > +++ b/arch/arm64/kvm/arch_timer.c > > @@ -480,7 +480,7 @@ static void timer_emulate(struct arch_timer_context *ctx) > > * scheduled for the future. If the timer cannot fire at all, > > * then we also don't need a soft timer. > > */ > > - if (!kvm_timer_irq_can_fire(ctx)) { > > + if (should_fire || !kvm_timer_irq_can_fire(ctx)) { > > Now, aligns to comment. > > soft_timer_cancel(&ctx->hrtimer); > > return; > > } > > > > Shall I resend this patch as regression fix of bee038a67487? I already have a patch written for this at [1], also getting rid of the soft_timer_cancel() call in the process (as it doesn't make much sense either). Please give it a go if you have a chance (though the whole branch might be of interest to you...). Thanks, M. [1] https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git/commit/?h=kvm-arm64/nv-6.2-WIP&id=effdcfa175c374a1740f60642d221ad2e930c978 -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel