Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp2358537pxy; Tue, 3 Aug 2021 04:41:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHcpWU6uwig6IRelFUcgAA2EvHusL0vKkqfMaC/GhHs1LV+UWqH2jxDaU8ZebuNrzxafYV X-Received: by 2002:a17:906:79a:: with SMTP id l26mr7929150ejc.192.1627990862179; Tue, 03 Aug 2021 04:41:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627990862; cv=none; d=google.com; s=arc-20160816; b=LTrggg1kb050EZym9d6OAg53QLObUnPUkF7sJKPFhhahS0FSHH2TjrbXMftufgMuD+ wI0bKSzSk8xIykJ0LhcZCQbpAp3/ipP0MVvTxHTAK/YhFg1qbaaSStCrf/rpxUuDNSVV sAqSIUxk0BRZif+TiyK5zzPUNJZqhnSbdI3Ur+8nhhwQ8Jdlzpg2Kh+pELgruqjPVCal gDkPZr2ryNBQUW29UXDHcLQLM/ILLQfJTnC+M/Epo5MM95XqzhmxmCdWGTplCbXBh2VW aT09U1R7oPddUAkT/myZk9wy6HVvF/nIH4YtGVR8XatakTUEC6w4dIHen9RK7Va9UEjq vRcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=UmVNfGoZY4xCeoLWYuH4sQBn8jsJ0wlkpb7HQ+aWoz8=; b=qeZtCMDf6Yw5oSOP7HU8cAtiZvvlkA9eqIrwAn7zWuCc5aukSLxrmtKfH8jXWsN512 fDVSN3gTaKjXu2ay9QMYA+0aMbTr7Jrao4oZx9tWSg41F7OCKPyj7mcrii3e7Ag/apnu OE4SeG8K4QyE2Lk0jvrWXxJ1SnYgGCdJSToqBZppuX3OuUd6tagUILj9ygeLlmSKDCZ9 NO/UFxgpeSEvrP5H5wpLEwM5VQ/JJfqZjqawg4F5+MSEci2WJG4wSmgt8g+tZMXB201g niOOVjmZ+nWLFOng+VOMMINKulsGjky6svO6IcKsA/r3D9TbUgbv/4UAip2+3bdCcLuf M2+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HV3jZitu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id kw22si13014317ejc.489.2021.08.03.04.40.38; Tue, 03 Aug 2021 04:41:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HV3jZitu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235910AbhHCLjP (ORCPT + 99 others); Tue, 3 Aug 2021 07:39:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:60214 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235656AbhHCLjN (ORCPT ); Tue, 3 Aug 2021 07:39:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 17CA360BD3; Tue, 3 Aug 2021 11:38:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627990742; bh=mME2Y3V/e+bRBo+xbl4UW9QXkdNerzgDg+UYaH+HLKI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=HV3jZitur7fF0Gywc+XPBQncXgR0TP63CgpxLPROPkzgdPlfCOj1xSDG1Oqy2W6en IaSGccub/3lkMnF1h1q2cAbKUiBJqciCauHUUxQP4RBIOPmKmSedJp1E8ftKlzqYWk lkot2D/XqzZUp/LVVR4MxI2rYAwbvzfSgFoX6ZDIeVIz6xK+6C2DMnFLZX6/GTrjA8 NSjqVj8ulxUwienXToTjFjg9UZx0DRyGfAnSDQHVqV1Qk03iunM55qd1h+kG/lQmqC 9DT0DRQa0DZcZG9pK3cFEVISG/Mbim8DNaVr6GlEufQub8K0J0nDhUNZlSswmGW+hI BjgwNcwiyuaTA== Date: Tue, 3 Aug 2021 12:38:56 +0100 From: Will Deacon To: Shameer Kolothum 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@huawei.com Subject: Re: [PATCH v3 1/4] KVM: arm64: Introduce a new VMID allocator for KVM Message-ID: <20210803113856.GA30853@willie-the-truck> References: <20210729104009.382-1-shameerali.kolothum.thodi@huawei.com> <20210729104009.382-2-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210729104009.382-2-shameerali.kolothum.thodi@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 29, 2021 at 11:40:06AM +0100, Shameer Kolothum wrote: > A new VMID allocator for arm64 KVM use. This is based on > arm64 ASID allocator algorithm. > > One major deviation from the ASID allocator is the way we > flush the context. Unlike ASID allocator, we expect less > frequent rollover in the case of VMIDs. Hence, instead of > marking the CPU as flush_pending and issuing a local context > invalidation on the next context switch, we broadcast TLB > flush + I-cache invalidation over the inner shareable domain > on rollover. > > Signed-off-by: Shameer Kolothum > --- [...] > +void kvm_arm_vmid_update(struct kvm_vmid *kvm_vmid) > +{ > + unsigned long flags; > + unsigned int cpu; > + u64 vmid, old_active_vmid; > + > + vmid = atomic64_read(&kvm_vmid->id); > + > + /* > + * Please refer comments in check_and_switch_context() in > + * arch/arm64/mm/context.c. > + */ > + old_active_vmid = atomic64_read(this_cpu_ptr(&active_vmids)); > + if (old_active_vmid && vmid_gen_match(vmid) && > + atomic64_cmpxchg_relaxed(this_cpu_ptr(&active_vmids), > + old_active_vmid, vmid)) > + return; > + > + raw_spin_lock_irqsave(&cpu_vmid_lock, flags); > + > + /* Check that our VMID belongs to the current generation. */ > + vmid = atomic64_read(&kvm_vmid->id); > + if (!vmid_gen_match(vmid)) { > + vmid = new_vmid(kvm_vmid); > + atomic64_set(&kvm_vmid->id, vmid); new_vmid() can just set kvm_vmid->id directly > + } > + > + cpu = smp_processor_id(); Why? Will