Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1327640ybt; Tue, 7 Jul 2020 13:00:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTzp6KGkjNy9lIWPtNChmSJPG4r8nSYYw3Q+UcZQ6RC3I4lTGUGRzIE0Uxe79A+/Fp4L4B X-Received: by 2002:a17:906:c30b:: with SMTP id s11mr50537719ejz.263.1594152013879; Tue, 07 Jul 2020 13:00:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594152013; cv=none; d=google.com; s=arc-20160816; b=01PNRczlR3kj4L+LOMkrHRQL/l/f4ZKxkwKSrz22Q6+eYyppI2n0Y/2duaO1kynEU7 9wLi118Q8rE14VH0ko3T8XS/++0NUi4J9rojbnD9mb6PzKtCLy1uK9RETQHJmjyOKHlM PiBpcu5W6TbNWqC1kgEHFCcUyURNwDCqjuCQDF2HkOkG/VwFkp5eeDmwlbU5L4iSg84H TSbVqjgfB1o4XwnFpAkkJLwqCGpYtY43YfPHMQxBXg/xDTMziX4nHeyvZcg4/t5OKG44 MOUfU9eEzz7p9hzW45ZfiuCISzHFwQ0KoABiKkIWIuQ7nqSyfSwbZtdl1lYNKUtukk6w Chyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=5iqp4P/isd/ynggELWuoJEw3n3//jsiZ1to37EMJGzI=; b=DFns9yN5UsELitHAttTQzuvQLn+oyE7KcHgx90GgdEZGQV/g+VukKBiz0jg5gkU4zi 171z8c887nqKMN52l/Zx68ynZsPQ/eo7whAay8/QG/Homca7HHVFrYufk5oJXsNB7OVm PTBjD36SqEqG+xxSO7GCOJVRX88q8QAjya3Ma983DLMohGPo4Ex7KPRF1UIzUtZ/rZm4 PY6T/ZxpP6vtcRNLYV/Od+Ant4TDrJWOAADh866bHDOwsSRZQDC1ffyNM5H6Pd6Hh/P8 TeGyl7+nHhm1eXYgm7SWLcF69OXRuFtkGKYeFEg8Ta8k5HTs4mMI5vU8aihp3cOwPxAm PWBA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v4si14482941ejx.555.2020.07.07.12.59.49; Tue, 07 Jul 2020 13:00:13 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728753AbgGGT47 (ORCPT + 99 others); Tue, 7 Jul 2020 15:56:59 -0400 Received: from mga06.intel.com ([134.134.136.31]:58111 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728701AbgGGT47 (ORCPT ); Tue, 7 Jul 2020 15:56:59 -0400 IronPort-SDR: zFr05g4WBMtT+hpM5NMJNTbxhporwZEwsM5zMJ2xuP7GAnJAdY9UDWPqlQ8xS0Vl8AhQF3CLwA qJGOMGphJ18w== X-IronPort-AV: E=McAfee;i="6000,8403,9675"; a="209215847" X-IronPort-AV: E=Sophos;i="5.75,324,1589266800"; d="scan'208";a="209215847" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jul 2020 12:56:58 -0700 IronPort-SDR: uJ2aiNFQi5DFX0DNPXct67t6vFZ3yboM/GmfyuVytv9hGVwtvRJZnmQbbU30y6f6nk/pAwVdwf YS/TRUNdd37A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,324,1589266800"; d="scan'208";a="427588555" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.152]) by orsmga004.jf.intel.com with ESMTP; 07 Jul 2020 12:56:58 -0700 Date: Tue, 7 Jul 2020 12:56:58 -0700 From: Sean Christopherson To: Peter Xu 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: <20200707195658.GK20096@linux.intel.com> References: <20200601115957.1581250-1-peterx@redhat.com> <20200601115957.1581250-3-peterx@redhat.com> <20200702230849.GL3575@linux.intel.com> <20200703184122.GF6677@xz-x1> <20200707061732.GI5208@linux.intel.com> <20200707195009.GE88106@xz-x1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200707195009.GE88106@xz-x1> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 07, 2020 at 03:50:09PM -0400, Peter Xu wrote: > On Mon, Jul 06, 2020 at 11:17:32PM -0700, Sean Christopherson wrote: > > On Fri, Jul 03, 2020 at 02:41:22PM -0400, Peter Xu wrote: > > > On Thu, Jul 02, 2020 at 04:08:49PM -0700, Sean Christopherson wrote: > > > > 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 */ > > > > Why not just set it? > > Because the value is useless even if set? :) It's useless when things go according to plan, but I can see it being useful if there's a bug that leads to consumption of a deleted memslot. Maybe not "useful" so much as "not misleading". > You mean in kvm_delete_memslot(), am I right? Yes. > > It's a single line of code, and there's more than one > > "shouldn't" in the above. > > If you want, I can both set it and add the comment. Thanks, Why bother with the comment? It'd be wrong in the sense that the as_id is always valid/accurate, even if npages == 0.