Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4809247imw; Tue, 19 Jul 2022 13:45:43 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tQd8DTT4Fc+NmeQ3ojiRFUl1bCmHijUzMcwL5MkRu6KlO3ct3Gaz1P94UHvlYypaxVDMGt X-Received: by 2002:a05:6a00:8c5:b0:510:6eae:6fa1 with SMTP id s5-20020a056a0008c500b005106eae6fa1mr36459449pfu.12.1658263543346; Tue, 19 Jul 2022 13:45:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658263543; cv=none; d=google.com; s=arc-20160816; b=eC+uXqoge0E/mEG9xfcOWKHDWfbyqLT0KPaTsAizwQNc99kHo74a6Jwnk4tM9vjC4w 2gxHJnI4APkqb5+iLv2fXrSg5EjUxTZkd2pqPCSK3Kw3eObwP+XpJ4MOnoLKtKsNRXTn ilf99HHVdFcScBTy2gxQfL11r3XSrRrbNfBlKK7nwFoKQAPPbGctu0Ubz+qrv1iqRFvN zvT0K32Q5N9EVZciY6ro4q/85MUGex78QhFx6dxP9g76g9mcUG+Xqd3uyMlNjYajkftz fAbh7H5wv5PLCYSepIfC6e2hbulX/nUQyEPaOef7BeNFCu2Yl3yTtBU1mrUwZIQl/Vcm sXRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=j8fpaezXRFwn4+Ho957RhCHI/1ApPqF3nvBcj0KrerQ=; b=JeWGBbI+K8OLEk7QDRa2x1UCUXkW0fIcpvqZb5NcvS6JqF9EAs6fAk2i/qAvGWGjr4 LkpKXrTYZ+0znO3VQzja7VJTcfMKS3rIVc3IY1wt97lc6anCVjz9DbyeiB9AyqoTWe0Y 0QvV3W6rQDX/pxCHm2MzMEP9sbu528Vh5D0PVeGmxpoxV0t9y03yE97vbsUgQ3QHKzxl /Les2P5Xe4mdAEMLluWw8pwtxVi2x8cEXwbdkvwUf8SH7NDC4MadyyAfDr7KV7gelyWv ulCc0/DRueXQIs4Kqm/wtnU8HoXf7VENqMtfwioPVlBmRwJIlkC5v+elJug29caREDLU Xn/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=mXe2UetS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v10-20020a63610a000000b00415c3d1136csi3786334pgb.409.2022.07.19.13.45.26; Tue, 19 Jul 2022 13:45:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=mXe2UetS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239940AbiGSUIG (ORCPT + 99 others); Tue, 19 Jul 2022 16:08:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231207AbiGSUIF (ORCPT ); Tue, 19 Jul 2022 16:08:05 -0400 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F01D25E83 for ; Tue, 19 Jul 2022 13:08:04 -0700 (PDT) Received: by mail-pg1-x52a.google.com with SMTP id bf13so14459659pgb.11 for ; Tue, 19 Jul 2022 13:08:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=j8fpaezXRFwn4+Ho957RhCHI/1ApPqF3nvBcj0KrerQ=; b=mXe2UetShJT3mLzz/cur2NABcA9POjjC3PHbHtwqtzKNj0GDrdKlgyB97jfGh39iRH 6fCgoLa0B3Jvn/8SpvXwTuxxvxjioNzdZZV5TYfVMMRh1YlQy6JZO6F+2So6YgVk79UX d0fjFavqFpt/MU5LVoTk2b9HAIWdpCv2ewrJaeC6uCycYpqwk/BDFK9UKWf92VI4IOBc ilA5sW/1Q/l4MiPFMUGJyLwQjQTXrH776VBkdu7l6vDD1hE28Eh8CGZcH4iMCXHrzDQe /UOosUdMpuh9TEvYBq+3SKHfECZXipfJF2GVDUTNLQ41+bxJ7gjPn8DekHN+QzfTj5Cw pPYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=j8fpaezXRFwn4+Ho957RhCHI/1ApPqF3nvBcj0KrerQ=; b=P/1wy1P8I+kmFpNkWXxXSFP3ADSZGeXJ3VEYBVUWlwchypc5mBrUS8C7tZbqklzHKB pYbBoLt/UIZCFHTuGhIE9Aivz8OgEp7iyYpdJpt3Xf4i5apN8xgDynMJrt1WBcEsutLj EmWv3igfj2gQub1a/4YgZOQ79qg0FsY2ZyhGBwWArWS6AHkpWeUHCFYhmxuIgnHPiyDu Zz96GvspclICYkYA7yUVzxl6K6hdmC7F1YUbyL7xCYkLG3Y7kpfQO32BlCg/c7GGXYV/ y5JL4FNOrsTW9srzFCrCnvIq1jGbi6LWdHbSoBvpl1AqigAfMvQbGTy09MYfte3x5NG6 v3Aw== X-Gm-Message-State: AJIora+s5L3SlwSaJmAaDgbt26WXN+tP6ucQ0XPqpq4PhlEb7eBz+0KK 7shnSoicSWyQVBde4tqN98MH9BJ+91bcow== X-Received: by 2002:a63:5b45:0:b0:416:7867:4298 with SMTP id l5-20020a635b45000000b0041678674298mr31589221pgm.58.1658261283495; Tue, 19 Jul 2022 13:08:03 -0700 (PDT) Received: from google.com (123.65.230.35.bc.googleusercontent.com. [35.230.65.123]) by smtp.gmail.com with ESMTPSA id j31-20020a63fc1f000000b00419ab8f8d2csm10360858pgi.20.2022.07.19.13.08.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Jul 2022 13:08:02 -0700 (PDT) Date: Tue, 19 Jul 2022 20:07:59 +0000 From: Sean Christopherson To: Lai Jiangshan Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini , Vitaly Kuznetsov , Maxim Levitsky , Lai Jiangshan Subject: Re: [PATCH 06/12] KVM: X86/MMU: Rename mmu_unsync_walk() to mmu_unsync_walk_and_clear() Message-ID: References: <20220605064342.309219-1-jiangshanlai@gmail.com> <20220605064342.309219-7-jiangshanlai@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220605064342.309219-7-jiangshanlai@gmail.com> X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jun 05, 2022, Lai Jiangshan wrote: > From: Lai Jiangshan > > mmu_unsync_walk() and __mmu_unsync_walk() requires the caller to clear > unsync for the shadow pages in the resulted pvec by synching them or > zapping them. > > All callers does so. > > Otherwise mmu_unsync_walk() and __mmu_unsync_walk() can't work because > they always walk from the beginning. > > And mmu_unsync_walk() and __mmu_unsync_walk() directly clear unsync bits > now, rename it. What about mmu_gather_unsync_shadow_pages()? I agree that "walk" isn't a great name, but IMO that's true regardless of when it updates the unsync bitmap. And similar to a previous complaint about "clear" being ambiguous, I don't think it's realistic that we'll be able to come up with a name the precisely and unambiguously describes what exactly is being cleared. Instead, regardless of what name we settle on, add a function comment. Probably in the patch that changes the clear_unsync_child_bit behavior. That's a better place to document the implementation detail. > Signed-off-by: Lai Jiangshan > --- > arch/x86/kvm/mmu/mmu.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c > index 2446ede0b7b9..a56d328365e4 100644 > --- a/arch/x86/kvm/mmu/mmu.c > +++ b/arch/x86/kvm/mmu/mmu.c > @@ -1773,7 +1773,7 @@ static inline void clear_unsync_child_bit(struct kvm_mmu_page *sp, int idx) > __clear_bit(idx, sp->unsync_child_bitmap); > } > > -static int __mmu_unsync_walk(struct kvm_mmu_page *sp, > +static int __mmu_unsync_walk_and_clear(struct kvm_mmu_page *sp, > struct kvm_mmu_pages *pvec) > { > int i, ret, nr_unsync_leaf = 0; > @@ -1793,7 +1793,7 @@ static int __mmu_unsync_walk(struct kvm_mmu_page *sp, > if (mmu_pages_add(pvec, child, i)) > return -ENOSPC; > > - ret = __mmu_unsync_walk(child, pvec); > + ret = __mmu_unsync_walk_and_clear(child, pvec); > if (ret < 0) > return ret; > nr_unsync_leaf += ret; > @@ -1818,7 +1818,7 @@ static int __mmu_unsync_walk(struct kvm_mmu_page *sp, > > #define INVALID_INDEX (-1) > > -static int mmu_unsync_walk(struct kvm_mmu_page *sp, > +static int mmu_unsync_walk_and_clear(struct kvm_mmu_page *sp, > struct kvm_mmu_pages *pvec) Please align indentation. > { > pvec->nr = 0; > @@ -1826,7 +1826,7 @@ static int mmu_unsync_walk(struct kvm_mmu_page *sp, > return 0; > > mmu_pages_add(pvec, sp, INVALID_INDEX); > - return __mmu_unsync_walk(sp, pvec); > + return __mmu_unsync_walk_and_clear(sp, pvec); > } > > static void kvm_mmu_page_clear_unsync(struct kvm *kvm, struct kvm_mmu_page *sp) > @@ -1962,7 +1962,7 @@ static int mmu_sync_children(struct kvm_vcpu *vcpu, > LIST_HEAD(invalid_list); > bool flush = false; > > - while (mmu_unsync_walk(parent, &pages)) { > + while (mmu_unsync_walk_and_clear(parent, &pages)) { > bool protected = false; > > for_each_sp(pages, sp, parents, i) > @@ -2279,7 +2279,7 @@ static int mmu_zap_unsync_children(struct kvm *kvm, > if (parent->role.level == PG_LEVEL_4K) > return 0; > > - while (mmu_unsync_walk(parent, &pages)) { > + while (mmu_unsync_walk_and_clear(parent, &pages)) { > struct kvm_mmu_page *sp; > > for_each_sp(pages, sp, parents, i) { > -- > 2.19.1.6.gb485710b >