Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2546651ybt; Fri, 3 Jul 2020 11:44:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPFNRWrjt5pEF7arGFauqC3kvrAS09iwrGTJcL2fuB6u8M1PWygRlB83eGb6WFkHvmpWcD X-Received: by 2002:a17:906:1394:: with SMTP id f20mr34246476ejc.114.1593801883275; Fri, 03 Jul 2020 11:44:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593801883; cv=none; d=google.com; s=arc-20160816; b=X/MrRaq+TaMZEfaMaXW78MEc9K6IWuG66MIlrIhdil5n0ZXd+TnZjpdOsbKLkcMSFg JRDixiyHB1NzJTQLA89ye/vMtqYlHVrx3E+frxj/u/9YQlecoBS1Jk2VB5iorhDiG72j wUwb20gsFb7VtlXBeTJB1mVqWCTdSKZqP0WHTud20Fzz/82cebPlbuif7I6q6KXS9AeM +VZFOtztFP2lUdLfS8bq5GJrpIB2kziyaY9qgFLDy+vw6TPXOAjoUc5Q5fCJoi03efqN ITTlRq9IMpK8ooXNL8fuj27DEQ+WPqWpSgpr3XWKv8IXak20J2BK9+g+DWfu/PrRXYbM wm0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=c83Dgu3F7bsHrP60t6VLlQzU3WYklyXESDcu0K3MgRU=; b=YB7hmJ0KI4GpM+WYABXwKaWh1KJQgjXFTLEtsuH0isym3rtCvDa18fjsnnLrodK6mW T1350+XV4bQQHoaskmuk9bC60zC/p7FwmtfkW25d9ZgTnpY1shwtA2/ch9v14583Jics I1zBpAJf2aNlSHS/ui+HFffpLmS7BZqihnEZnCSF5W7C6BzrudrjLh6/QuB0LmH0RuQz rJ3oKqnkv9fTbgpir8bYc41gYEY9yikZGRLso0KwtIvVcaTqyY8lgcl91L4HXS//bGB9 ny31b0D8HPc9Dh+PqlSo8QaA6K8Ki8WPwYs1UD+23Aope7zpApxETh8mv/oMRKakEIhi Bm5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Q6Ej3TQC; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v13si8516565edq.56.2020.07.03.11.44.20; Fri, 03 Jul 2020 11:44:43 -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=@redhat.com header.s=mimecast20190719 header.b=Q6Ej3TQC; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726513AbgGCSla (ORCPT + 99 others); Fri, 3 Jul 2020 14:41:30 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:53674 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726148AbgGCSl3 (ORCPT ); Fri, 3 Jul 2020 14:41:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593801688; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=c83Dgu3F7bsHrP60t6VLlQzU3WYklyXESDcu0K3MgRU=; b=Q6Ej3TQCkc1Qeg2ZcIHOMLY2zCWH48g4Mvp0SUVqwQbeTsNHjVPXf0duSYvqmXCXcSnRd1 HgS+wDmpihf605mCgQCFktrdClz8/X4Hg/MQ/igD/8TwFXEoD10hDwPyqND1A93k2BhH19 mqmSA9UpP5nJHBj16J49jDfrJvU874o= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-27-H8CCHlhONMmkprjaoBDMMg-1; Fri, 03 Jul 2020 14:41:25 -0400 X-MC-Unique: H8CCHlhONMmkprjaoBDMMg-1 Received: by mail-qt1-f198.google.com with SMTP id i5so22379649qtw.3 for ; Fri, 03 Jul 2020 11:41:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=c83Dgu3F7bsHrP60t6VLlQzU3WYklyXESDcu0K3MgRU=; b=L3DA5GEA4TCsMLO6yG83zBnqRTyK559f+TFCMhavkl9J/1tpzzQeIWuky0xvHmvR6p YK6A2QKzYLw2ZphfKEMrt0VePIA4gsMYKxXC8SCaEJbmcx1aa67K56fIHqzpi2qBilYy ue1xTvMBs4KItJSz6qyZlfyMeOGu6ZiBfJ7HojIX2q3qDp/R31nEV9vWj4Aaf5Re93rp tOC1W783EX2al8lV4rD6CqzaNBhVlgRsV42tU6ao6Tp+G1hI0Gg83PPfUx3lzB7HZFQn I1UyaTx8ZWLOo6pojCrcpzA2jfcxZ7B41pfgIuSjttXI/v1O/szswwFgXIiSgEl8i+Eq Anug== X-Gm-Message-State: AOAM530UgW887K039SpJZjSpecIChlfwnjUYhVio9Da+y4iYnZdA0gMy TdGkkJSwlFauRnnE9ZwzCwiIDmDJc9cRCtKz/RaJx0nN9F1UHArOcAfYFOa44IcFQg+sd8wYrnP L/N13YnxAPHM5En8gSIRSPYIa X-Received: by 2002:a0c:db8a:: with SMTP id m10mr36623055qvk.21.1593801684762; Fri, 03 Jul 2020 11:41:24 -0700 (PDT) X-Received: by 2002:a0c:db8a:: with SMTP id m10mr36623028qvk.21.1593801684349; Fri, 03 Jul 2020 11:41:24 -0700 (PDT) Received: from xz-x1 ([2607:9880:19c0:32::2]) by smtp.gmail.com with ESMTPSA id a28sm10753840qko.45.2020.07.03.11.41.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jul 2020 11:41:23 -0700 (PDT) Date: Fri, 3 Jul 2020 14:41:22 -0400 From: Peter Xu To: Sean Christopherson Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, "Dr . David Alan Gilbert" , Andrew Jones , Vitaly Kuznetsov , Paolo Bonzini , "Michael S . Tsirkin" , Jason Wang , Kevin Tian Subject: Re: [PATCH v10 02/14] KVM: Cache as_id in kvm_memory_slot Message-ID: <20200703184122.GF6677@xz-x1> References: <20200601115957.1581250-1-peterx@redhat.com> <20200601115957.1581250-3-peterx@redhat.com> <20200702230849.GL3575@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200702230849.GL3575@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 02, 2020 at 04:08:49PM -0700, Sean Christopherson wrote: > On Mon, Jun 01, 2020 at 07:59:45AM -0400, Peter Xu wrote: > > Cache the address space ID just like the slot ID. It will be used in > > order to fill in the dirty ring entries. > > > > Suggested-by: Paolo Bonzini > > Suggested-by: Sean Christopherson > > Signed-off-by: Peter Xu > > --- > > include/linux/kvm_host.h | 1 + > > virt/kvm/kvm_main.c | 1 + > > 2 files changed, 2 insertions(+) > > > > diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h > > index 01276e3d01b9..5e7bbaf7a36b 100644 > > --- a/include/linux/kvm_host.h > > +++ b/include/linux/kvm_host.h > > @@ -346,6 +346,7 @@ struct kvm_memory_slot { > > unsigned long userspace_addr; > > u32 flags; > > short id; > > + u16 as_id; > > }; > > > > static inline unsigned long kvm_dirty_bitmap_bytes(struct kvm_memory_slot *memslot) > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > > index 74bdb7bf3295..ebdd98a30e82 100644 > > --- a/virt/kvm/kvm_main.c > > +++ b/virt/kvm/kvm_main.c > > @@ -1243,6 +1243,7 @@ int __kvm_set_memory_region(struct kvm *kvm, > > if (!mem->memory_size) > > return kvm_delete_memslot(kvm, mem, &old, as_id); > > This technically needs to set as_id in the deleted memslot. I highly doubt > it will ever matter from a functionality perspective, but it'd be confusing > to encounter a memslot whose as_id did not match that of its owner. Yeah it shouldn't matter because as_id is directly passed in to look up the pointer of kvm_memslots in kvm_delete_memslot, and memslot->as_id shouldn't be further referenced. I can add a comment above if this can clarify things a bit: + u16 as_id; /* cache of as_id; only valid if npages != 0 */ Thanks, -- Peter Xu