Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1548830iog; Tue, 14 Jun 2022 08:12:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygwqit1o6hOjYN+wR2fg8hmcE2Q8HGiQiTgCbP0hM5GSPg1OiBEJYhwykSpzhbRK8ZOsPU X-Received: by 2002:a17:906:3793:b0:702:eea9:843a with SMTP id n19-20020a170906379300b00702eea9843amr4716753ejc.465.1655219543689; Tue, 14 Jun 2022 08:12:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655219543; cv=none; d=google.com; s=arc-20160816; b=Umo5rTxiGdV+RZcBZm6cXral7DtPUM4T/h8+5BZ4l7iuM0scp8aHQRCZ8jnCqxUDf2 UjXXk6ifJocdPW+PYETvQLyjf6i+LKpb4SViQWhy6aSGohsyWjpbFaXb3Xhi/tpWRfzo 0r5ZMAXxmPs08iNsVo9A7ZJZAZAQ59rBDgcqjvoO21QgcBJTe2XKnk+yi+CA43bZTV2V jooqU0sQMEBzGyZ3dhuZfdg+qCabPnF4pSLirsr+iV9y9OarHXM73Qfi7XXV2yIWJpMm YYmyFM+0N+fEzLVipndpWm4qBb5rGo0CldZfcK7uHnH2Z2Eijd0dGJ6yCbHuFIpmqxiv iBTg== 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=uCN2gj0r2ydsfLcZI1sFwWz1Fp2OKP8Km+3JkrgTjRM=; b=HXuKbfT6UrSYcZ+leEf5pZoWqgXQKTHB3Ih2gQ9+MT/wg+PerU1dwoWjsOfFpjWVKJ wS5D1U87cutjyFBWDSD/HaF5MKWn/Bvbo3pzuAl2XOaGCFD6yZLpEtRzSTLX4U2kc2P9 59F0IPphQnoQapay2vyJ5bcqZgbBpume+S1AbdA+ivu3wcYCmu/T+HduEuPR3vtjiMiB /Z2hDBE2WuQnT2G0bCFpo5sDYVR72jVqPgjFX9c1HvG49cyGcbKwDhgVvYWAra2UGvYN nivi0cGoO1JJ3rK89CE/mn/6Po8TjlwN0+4Su7xuVvcB1cV/s3HRlSwlMQ/+eITd2QDg xw4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Ekx5DQ+H; 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 hv11-20020a17090760cb00b007048c0e873esi12346798ejc.172.2022.06.14.08.11.57; Tue, 14 Jun 2022 08:12:23 -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=Ekx5DQ+H; 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 S1348520AbiFNPA1 (ORCPT + 99 others); Tue, 14 Jun 2022 11:00:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344219AbiFNPAX (ORCPT ); Tue, 14 Jun 2022 11:00:23 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 037F83DDE7 for ; Tue, 14 Jun 2022 08:00:23 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id q12-20020a17090a304c00b001e2d4fb0eb4so12004028pjl.4 for ; Tue, 14 Jun 2022 08:00:22 -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=uCN2gj0r2ydsfLcZI1sFwWz1Fp2OKP8Km+3JkrgTjRM=; b=Ekx5DQ+HUHoSy6kumqYNnkdP9uUsany7Jp1UDBAeYOqVfAh5D+QvFnZtUvpNNK6A1N SND3VfsbuAxMkLo8Hei66R2cs7TpHH74Ih2idmiqz1PxUV3KeAoc82O8bZ2cEGCKzcBy gZDLvH/YQISqZmOf8yt1U8xR/02ZaXtv0MFfrqoPnjMCYXSllEXEH9yhGqRyPoik8tnY BzEOS4b9X5X+7Sd3xGYDipCLfgciwLZZ09qbPk85kHfGRl3OViI6jgC0k1+WrzVpWZyG PEzzC6WH5rFW6vvAIB/h7mfsCc2Fu+1wkhILcYBAQXYsCNeYnlZMMnQvihOV9H+IU0V6 PXxg== 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=uCN2gj0r2ydsfLcZI1sFwWz1Fp2OKP8Km+3JkrgTjRM=; b=JG8e7B3GKqAxkfMuRvIXCQV+vtDrnYprot/EZbwYn5BMYKSZe372oOiHUUIxY/9uzw 2AbXiuFnMYjIT7FeC2xG/adUgcS//ibr9WU9xPVx2hL0vis8qPe33k2q1S2BPzis0ncx 8kYTC7+l+ZlIiBYMEcQ/grynGHZNyTzpuw67w5aUgo45/AdyJI5ilpk6i9quIl+YSy3t kkxBYTfNdJlWkbvXryxOiIHcicoL7MkPVeertkeZPeaWf1GKji8TM+kvXzOpMHkmC7ZF yhFvV5dtyTLupHN9GvJeqDoG1V8S1CEHvfNAQMlKMaq1Bishi9ZwVPHJWN+hA+zb7EVW D0jw== X-Gm-Message-State: AJIora+8MxDAsaOdIInH58GIkRSo9xG03WKKaJpazcCoaZ1MU5lXk572 W0EQ+UVN39eo44/qAP8xrdyu9g== X-Received: by 2002:a17:90a:e28e:b0:1ea:c3c5:bc61 with SMTP id d14-20020a17090ae28e00b001eac3c5bc61mr4679621pjz.15.1655218822247; Tue, 14 Jun 2022 08:00:22 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id f13-20020a170902684d00b0015e8d4eb26csm7343256pln.182.2022.06.14.08.00.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jun 2022 08:00:21 -0700 (PDT) Date: Tue, 14 Jun 2022 15:00:18 +0000 From: Sean Christopherson To: Bo Liu Cc: pbonzini@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] KVM: Use consistent type for return value of kvm_mmu_memory_cache_nr_free_objects() Message-ID: References: <20220614093222.25387-1-liubo03@inspur.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220614093222.25387-1-liubo03@inspur.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, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham 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 Tue, Jun 14, 2022, Bo Liu wrote: > The return value type of the function rmap_can_add() is "bool", and it will > returns the result of the function kvm_mmu_memory_cache_nr_free_objects(). > So we should change the return value type of > kvm_mmu_memory_cache_nr_free_objects() to "bool". > > Signed-off-by: Bo Liu > --- > include/linux/kvm_host.h | 2 +- > virt/kvm/kvm_main.c | 4 ++-- > 2 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h > index c20f2d55840c..a399a7485795 100644 > --- a/include/linux/kvm_host.h > +++ b/include/linux/kvm_host.h > @@ -1358,7 +1358,7 @@ void kvm_flush_remote_tlbs(struct kvm *kvm); > > #ifdef KVM_ARCH_NR_OBJS_PER_MEMORY_CACHE > int kvm_mmu_topup_memory_cache(struct kvm_mmu_memory_cache *mc, int min); > -int kvm_mmu_memory_cache_nr_free_objects(struct kvm_mmu_memory_cache *mc); > +bool kvm_mmu_memory_cache_nr_free_objects(struct kvm_mmu_memory_cache *mc); > void kvm_mmu_free_memory_cache(struct kvm_mmu_memory_cache *mc); > void *kvm_mmu_memory_cache_alloc(struct kvm_mmu_memory_cache *mc); > #endif > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index a67e996cbf7f..2872569e3580 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -394,9 +394,9 @@ int kvm_mmu_topup_memory_cache(struct kvm_mmu_memory_cache *mc, int min) > return 0; > } > > -int kvm_mmu_memory_cache_nr_free_objects(struct kvm_mmu_memory_cache *mc) > +bool kvm_mmu_memory_cache_nr_free_objects(struct kvm_mmu_memory_cache *mc) Absolutely not, the name of the function is "nr_free_objects". Renaming it to "has_free_objects" is not a net positive IMO. If we really care about returning a bool then we can tweak rmap_can_add(). diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 17252f39bd7c..047855d134da 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -1018,7 +1018,7 @@ static bool rmap_can_add(struct kvm_vcpu *vcpu) struct kvm_mmu_memory_cache *mc; mc = &vcpu->arch.mmu_pte_list_desc_cache; - return kvm_mmu_memory_cache_nr_free_objects(mc); + return !!kvm_mmu_memory_cache_nr_free_objects(mc); } static void rmap_remove(struct kvm *kvm, u64 *spte)