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=-11.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 7E4F1C41537 for ; Tue, 3 Aug 2021 15:32:31 +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 4170161029 for ; Tue, 3 Aug 2021 15:32:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4170161029 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ePIHSYeqBGcdP79DObkCE/TI3PErnVWL5NmAsYg8Xx8=; b=akmYn+uWiEAxtA ni1bdqXJs9zGeGY6HokcsH0Mwwe09zXUTGvPkF/BjRePVg9vfnQ12C8ZH5irU75u0Qda12S13s8lt iMHw2JxOmPIh/ktMjWrHI4IrXBHlRWDFH/WLz7hHcsLu9Dm9ia0QqS7ZAg6B3pIUIASJUTQUYZ2Xz NmdTc+jdletBVUjMdlm8IcXSoOnxE8WwzEd93P/bt9rHLYcecpBDI7RS2f8+ETXrLvEj+H5W+bMY7 MbjUoXOhwXH/MOb/Ql0wE9nCW2smhIyBkyIFtWq3PA5RHunVvZjSIhPLV7yOMudnDgcZEXwxR8EZN mj/n6ulr4iPoQTBDBi1g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAwNS-003Pa3-8J; Tue, 03 Aug 2021 15:30:46 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAwNO-003PZM-RE for linux-arm-kernel@lists.infradead.org; Tue, 03 Aug 2021 15:30:44 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7489260F94; Tue, 3 Aug 2021 15:30:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1628004642; bh=HTCLwdKyT6siX/NNQAkgV9S50hfCToi2PQiR46wzJOA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UNa36HzG2X5o+mXj0JkamR1gwcNOzeK4UjQ7rYywhP8Aj5lkxhXxNONBj21H9y3hc LBDzzuDvwA6CsUouIl/cS0FGo0rVrLORLPxEucgSxg2RF2fZeLJ1oi4DzULM24kT17 vg/lxy+sNjTy/FyuWZ+Y1N+ttGVEdMSE5BUWCCeOnNZEZh7Z8SXYJtXsVp0qBxKTRY w/pRHZ8m8Nf8RSBhpE8AXQR/OGyjpAGqXi42WBkAfhYj/TwmJRQiYEUfhGNBgrU2MD MlEGZNh6pSYXVkhHmY/v0Wfg/6c4OeyMHLI2r8d6U6PxfCE84mLxlSZUjkARU+p7+8 cMDi/re1tKgIA== Date: Tue, 3 Aug 2021 16:30:37 +0100 From: Will Deacon 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 Message-ID: <20210803153036.GA31125@willie-the-truck> References: <20210729104009.382-1-shameerali.kolothum.thodi@huawei.com> <20210729104009.382-5-shameerali.kolothum.thodi@huawei.com> <20210803114034.GB30853@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210803_083042_944169_77603F4B X-CRM114-Status: GOOD ( 21.63 ) 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 Tue, Aug 03, 2021 at 12:55:25PM +0000, Shameerali Kolothum Thodi wrote: > > > 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. Why didn't you say so?! > > 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 I think we have to be really careful not to run into the "suspended animation" problem described in ae120d9edfe9 ("ARM: 7767/1: let the ASID allocator handle suspended animation") if we go down this road. Maybe something along the lines of: ROLLOVER * Take lock * Inc generation => This will force everybody down the slow path * Record active VMIDs * Broadcast TLBI => Only active VMIDs can be dirty => Reserve active VMIDs and mark as allocated VCPU SCHED IN * Set active VMID * Check generation * If mismatch then: * Take lock * Try to match a reserved VMID * If no reserved VMID, allocate new VCPU SCHED OUT * Clear active VMID but I'm not daft enough to think I got it right first time. I think it needs both implementing *and* modelling in TLA+ before we merge it! Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel