Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3173040pxb; Mon, 24 Jan 2022 04:11:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJxXdPxHxdX+wcfCS6IMhWTuxebjwBmxXFMJuqw0nC3K+2hqOabcpSPUP8ZVxdBxbrz7RzfP X-Received: by 2002:a17:90a:f982:: with SMTP id cq2mr1636754pjb.36.1643026290862; Mon, 24 Jan 2022 04:11:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643026290; cv=none; d=google.com; s=arc-20160816; b=wMWMevJZf/d3O2N12uyrI8RSmZnztEUWhzJRVQ9XWwlw3rawK6UTP6nNq88wf8FxHP 8BK3wxWQed7F7M3u7Tr3IOnTUdtOe2RAxKVXFYZheTzWbO9pFag1Uexv1GL3CTiL2Twh xDMhdGQpzF9HsFO0HXMqxXsmVibRsnzZKwt1sQFJFmk6nfORI656K8D+XsU9DHYN5IKS dUyKKxd04A+Zu5M3BNmgNF5SfJP0z1YcdFd6+rwEKnBl0CRv+SIFtTgtHNQ2HkUBde9i Sd4UepeESd2JZt2J+oep+TuQVaJNfCc6rdS5pR7wlFygmbI4EKWegaxvB6YR4g9rb/Ps L6Xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=fXTatFQVxk5Bi3xsp9CFfQ0rYZTcQkLIFRbBZJuCKTo=; b=MdBoLO6DSvS6Zr198PVW2eEZd3glV6rvUH4GJ/DOb7SeGqJzipwSWjYhtE7zWq/uGc 7AO8IhF90cR/X/GXxqw/KwyI+zPW/4RVgYCHXq+EVCJW7bGXEe4r3LrJt2yzpFe7WiqY +UPF30FtRyyCh3UZMN5i3IEv1MooU+t1Opj61FK4oUd8T7mP2qws6J5vaBvoYp9N5gRe dliFnll3DGb5nnQMddJRfdM7kYnScPS4WYLN0uZQS47wnk6DPu1Gcac1wLf9REi8DDcg Ey6kd0Mod8/2CeKKmuRlu4+SBslyDFtF/YWS+SzTKd5Ok71hmQDQ6/h02kIp/3hCQ1oH 2EFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=KYb54rPH; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e127si13061410pgc.58.2022.01.24.04.11.19; Mon, 24 Jan 2022 04:11:30 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=KYb54rPH; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239634AbiAWSkP (ORCPT + 99 others); Sun, 23 Jan 2022 13:40:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239653AbiAWSkK (ORCPT ); Sun, 23 Jan 2022 13:40:10 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EDADC06174E; Sun, 23 Jan 2022 10:40:08 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id d1so13469511plh.10; Sun, 23 Jan 2022 10:40:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=fXTatFQVxk5Bi3xsp9CFfQ0rYZTcQkLIFRbBZJuCKTo=; b=KYb54rPHkbyc69CRDBpNpVXaOnbgnehqVIcw6Q5nYZrUJqD8fYG2PdedR79iLsupu1 0gdBCwGbPIeYyZXmni9s7ZZpmKmo/Qkt6ciMlPncE4deOuznLGJzZl1K94T185JjDU1/ 0BM4tN7Pc3cUFGARdyGOI4WjOia7CvHbWBmFiJQomUMYAPygd6mJY/DqSogM2u5pn9Al mLIiLcJHMr9gmdThRmWN027YvK50UezK0LFgIFkLjtOSJtI19b+k2G8Scgm6vJnRW1yL NAcnbU0VWi26fHR+siKm19tyEpaeiFoGlNWzQNa+ac8t06cAXMt05iN57RqKTVDHGZd7 reYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fXTatFQVxk5Bi3xsp9CFfQ0rYZTcQkLIFRbBZJuCKTo=; b=gY2zTaPAOGGcOun3NSiwPOGJJ71sZn0VRWIwu4ehkfUYSLlm9lX6hzhRmXopTkHBSV qAsRnBOZ9cGxvlZKTur/+fnlQsthSgp0296bMII2f86EZzmLQMQHe3sf1ntRzx3CAjSH aTcknjGC6qF+x1j5+uPQIgVQKGUbA3Hdf6CNvJvcQP79WRYLXWbjcfNegz7n8wnnQG8D QP/M7fdwCdfrNS7+CGO2VnGBT9+yYmY791KTkiOL4QFoLmi3/Sjal3YGD+XiK1XJHQYZ iQLrfZDXsUT7oQHYWGCgN7Ki+SXoX4xaRHRqyzV6Jawghnk7NXk8JzgKycd5w3UvyNzw E6/Q== X-Gm-Message-State: AOAM532QpD+NZ2y4UuKCqTBZ7ylfKMylbzsETBYsinYE4V8QnB31PXEJ IV1OYbB1nxkKQOw7cmtcqNU= X-Received: by 2002:a17:902:7844:b0:14a:9cff:66c7 with SMTP id e4-20020a170902784400b0014a9cff66c7mr11824524pln.14.1642963207648; Sun, 23 Jan 2022 10:40:07 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id m13sm10828821pjl.39.2022.01.23.10.40.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:40:07 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , x86@kernel.org, kvm@vger.kernel.org Subject: [PATCH 06/54] x86/kvm: replace bitmap_weight with bitmap_empty where appropriate Date: Sun, 23 Jan 2022 10:38:37 -0800 Message-Id: <20220123183925.1052919-7-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In some places kvm/hyperv.c code calls bitmap_weight() to check if any bit of a given bitmap is set. It's better to use bitmap_empty() in that case because bitmap_empty() stops traversing the bitmap as soon as it finds first set bit, while bitmap_weight() counts all bits unconditionally. Signed-off-by: Yury Norov --- arch/x86/kvm/hyperv.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index 6e38a7d22e97..2c3400dea4b3 100644 --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c @@ -90,7 +90,7 @@ static void synic_update_vector(struct kvm_vcpu_hv_synic *synic, { struct kvm_vcpu *vcpu = hv_synic_to_vcpu(synic); struct kvm_hv *hv = to_kvm_hv(vcpu->kvm); - int auto_eoi_old, auto_eoi_new; + bool auto_eoi_old, auto_eoi_new; if (vector < HV_SYNIC_FIRST_VALID_VECTOR) return; @@ -100,16 +100,16 @@ static void synic_update_vector(struct kvm_vcpu_hv_synic *synic, else __clear_bit(vector, synic->vec_bitmap); - auto_eoi_old = bitmap_weight(synic->auto_eoi_bitmap, 256); + auto_eoi_old = bitmap_empty(synic->auto_eoi_bitmap, 256); if (synic_has_vector_auto_eoi(synic, vector)) __set_bit(vector, synic->auto_eoi_bitmap); else __clear_bit(vector, synic->auto_eoi_bitmap); - auto_eoi_new = bitmap_weight(synic->auto_eoi_bitmap, 256); + auto_eoi_new = bitmap_empty(synic->auto_eoi_bitmap, 256); - if (!!auto_eoi_old == !!auto_eoi_new) + if (auto_eoi_old == auto_eoi_new) return; down_write(&vcpu->kvm->arch.apicv_update_lock); -- 2.30.2