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 X-Spam-Level: X-Spam-Status: No, score=-14.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75875C4338F for ; Tue, 3 Aug 2021 13:15:00 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 30A4E6056B for ; Tue, 3 Aug 2021 13:15:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 30A4E6056B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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:In-Reply-To:References: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Z4izt1R59ibcQ9H7s1A13qv++fynoTzA9UjzBIntkNI=; b=dcTHbgdTCwFbUK HUm0xX44oS1OvO3HpAYOgsU1OPIRbIzFHWbno4YtBEZNioBVO/cDWj0/7XCj29vNhGVn6Bw7xmXJp JXg3cFOOt6qHGD6GY6qzthzOb58Il/y0Z/94Ds+nkwAFft4ihjNHMalLh40I/tgKt5Y8/7+rfzd30 winc8mL82t77h+ZbJZXqG8DpVRqmFNJGH0rdKs1ePyEAiOGrowYy5VND6PHELPH9+/QpE2CvNLtj5 qzwKE0FjnLw3ej9NAfyQbs6LT9fgUxBgPkh/FAdT8un3ha7Xg8OnvtO6OnUbw1dBFJRlBqdgaAgyL M19ExSl7n5+rjEpLXlyQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAuDo-002u49-Gj; Tue, 03 Aug 2021 13:12:40 +0000 Received: from szxga04-in.huawei.com ([45.249.212.190]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAtxD-002mX0-2z for linux-arm-kernel@lists.infradead.org; Tue, 03 Aug 2021 12:55:33 +0000 Received: from dggems705-chm.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4GfFB20Fmzz18Nbw; Tue, 3 Aug 2021 20:51:38 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by dggems705-chm.china.huawei.com (10.3.19.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 3 Aug 2021 20:55:27 +0800 Received: from lhreml710-chm.china.huawei.com ([169.254.81.184]) by lhreml710-chm.china.huawei.com ([169.254.81.184]) with mapi id 15.01.2176.012; Tue, 3 Aug 2021 13:55:25 +0100 From: Shameerali Kolothum Thodi To: Will Deacon CC: "linux-arm-kernel@lists.infradead.org" , "kvmarm@lists.cs.columbia.edu" , "linux-kernel@vger.kernel.org" , "maz@kernel.org" , "catalin.marinas@arm.com" , "james.morse@arm.com" , "julien.thierry.kdev@gmail.com" , "suzuki.poulose@arm.com" , "jean-philippe@linaro.org" , "Alexandru.Elisei@arm.com" , "qperret@google.com" , Linuxarm Subject: RE: [PATCH v3 4/4] KVM: arm64: Clear active_vmids on vCPU schedule out Thread-Topic: [PATCH v3 4/4] KVM: arm64: Clear active_vmids on vCPU schedule out Thread-Index: AQHXhGar1JrryboKrU+7h+yU/0K2/6thny2AgAAaZCA= Date: Tue, 3 Aug 2021 12:55:25 +0000 Message-ID: References: <20210729104009.382-1-shameerali.kolothum.thodi@huawei.com> <20210729104009.382-5-shameerali.kolothum.thodi@huawei.com> <20210803114034.GB30853@willie-the-truck> In-Reply-To: <20210803114034.GB30853@willie-the-truck> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.47.86.18] MIME-Version: 1.0 X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210803_055531_592160_A50254D2 X-CRM114-Status: GOOD ( 23.52 ) 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="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org > -----Original Message----- > From: Will Deacon [mailto:will@kernel.org] > Sent: 03 August 2021 12:41 > To: Shameerali Kolothum Thodi > Cc: linux-arm-kernel@lists.infradead.org; kvmarm@lists.cs.columbia.edu; > linux-kernel@vger.kernel.org; maz@kernel.org; catalin.marinas@arm.com; > james.morse@arm.com; julien.thierry.kdev@gmail.com; > suzuki.poulose@arm.com; jean-philippe@linaro.org; > Alexandru.Elisei@arm.com; qperret@google.com; Linuxarm > > Subject: Re: [PATCH v3 4/4] KVM: arm64: Clear active_vmids on vCPU > schedule out > = > On Thu, Jul 29, 2021 at 11:40:09AM +0100, Shameer Kolothum wrote: > > Like ASID allocator, we copy the active_vmids into the > > reserved_vmids on a rollover. But it's unlikely that > > every CPU will have a=A0vCPU as current task and we may > > end up unnecessarily=A0reserving the VMID space. > > > > Hence, clear active_vmids when scheduling out a vCPU. > > > > Suggested-by: Will Deacon > > Signed-off-by: Shameer Kolothum > > > --- > > arch/arm64/include/asm/kvm_host.h | 1 + > > arch/arm64/kvm/arm.c | 1 + > > arch/arm64/kvm/vmid.c | 6 ++++++ > > 3 files changed, 8 insertions(+) > > > > diff --git a/arch/arm64/include/asm/kvm_host.h > b/arch/arm64/include/asm/kvm_host.h > > index bb993bce1363..d93141cb8d16 100644 > > --- a/arch/arm64/include/asm/kvm_host.h > > +++ b/arch/arm64/include/asm/kvm_host.h > > @@ -687,6 +687,7 @@ extern unsigned int kvm_arm_vmid_bits; > > int kvm_arm_vmid_alloc_init(void); > > void kvm_arm_vmid_alloc_free(void); > > void kvm_arm_vmid_update(struct kvm_vmid *kvm_vmid); > > +void kvm_arm_vmid_clear_active(void); > > > > static inline void kvm_arm_pvtime_vcpu_init(struct kvm_vcpu_arch > *vcpu_arch) > > { > > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > > index 077e55a511a9..b134a1b89c84 100644 > > --- a/arch/arm64/kvm/arm.c > > +++ b/arch/arm64/kvm/arm.c > > @@ -435,6 +435,7 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) > > kvm_timer_vcpu_put(vcpu); > > kvm_vgic_put(vcpu); > > kvm_vcpu_pmu_restore_host(vcpu); > > + kvm_arm_vmid_clear_active(); > > > > vcpu->cpu =3D -1; > > } > > diff --git a/arch/arm64/kvm/vmid.c b/arch/arm64/kvm/vmid.c > > index 5584e84aed95..5fd51f5445c1 100644 > > --- a/arch/arm64/kvm/vmid.c > > +++ b/arch/arm64/kvm/vmid.c > > @@ -116,6 +116,12 @@ static u64 new_vmid(struct kvm_vmid > *kvm_vmid) > > return idx2vmid(vmid) | generation; > > } > > > > +/* Call with preemption disabled */ > > +void kvm_arm_vmid_clear_active(void) > > +{ > > + atomic64_set(this_cpu_ptr(&active_vmids), 0); > > +} > = > I think this is very broken, as it will force everybody to take the > slow-path when they see an active_vmid of 0. Yes. I have seen that happening in my test setup. > It also doesn't solve the issue I mentioned before, as an active_vmid of 0 > means that the reserved vmid is preserved. > = > Needs more thought... How about we clear all the active_vmids in kvm_arch_free_vm() if it matches the kvm_vmid->id ? But we may have to hold the lock = there. Thanks, Shameer = _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel