Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3175159pxb; Mon, 24 Jan 2022 04:14:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJyw83Q9drvYMbiCJ35QLv723mBuxW3Xx4PngilFpHlg3dZOubv6AvW/JUByOBHnKz4SB6KC X-Received: by 2002:a63:d243:: with SMTP id t3mr11512004pgi.437.1643026474327; Mon, 24 Jan 2022 04:14:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643026474; cv=none; d=google.com; s=arc-20160816; b=IBtDvMRBwv3EmTNiCYuUSPuIgoSV/zmrkzWwIWvgZOhagW5+EvGYZQVVT2XPu1A4iJ +b1UJsge28m2cNQfLCYhfNdeoKfiqvoXVmpvXjEj1KHv4EQt6Tyqi4N6y+nzAnpc+opF ypmwniRapkwBe99n/lnCEs5SHx4ryCjFVddXAk9uXZqV804youSh1rggyIaB71GnzSyZ OkmUIrqBSeW7gc7NJbhFzHFo0I5ksmkjUvFMBe6Z1+Mo09x06Peh3ltC0Pw9ph97HWYP 6iRJS09muTzsxSSgB2jAoZfM5ZyUdQqeQ/FWDNG57t/aQc1hHwYgeGgCCygoMP5Jp+PR v1kg== 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=/VgvGoSrjM7RHhvz4oz6UhP4t05IzW+FafmG/hxmK+g=; b=pVNGMynLH4kFlS4S4QisRNHQMHGv4khk4cAuIAKhOd9JBnUaaygDEsDITiLCz2fQmn HYsEGhBYqv4VUV/jIF5+spgosO+K5n+NOnNe7T8hC2r/Etq7j27tkMzkOOoTSCeiio2N +qzFECGfEZzvVHcze64IzojuW7+4YjXYBhjJRkKZp8//IEcXQjhliJBIXGlEFHLcdhP/ R7E6VxHi3wQ2G7WgWuV0Ue7rtN0oF3OdtjnwMkv0vn/unYcuO60gRhC2rnMZgzoRV/V0 JbRfcrFhHcnxak9X6paTS/MSUCfzkYcsXYg8fdWOhdAzZH4uDfP1AA0M177TYVtilWy0 8pGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LtksDaUo; 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 u18si15084294plg.8.2022.01.24.04.14.21; Mon, 24 Jan 2022 04:14:34 -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=LtksDaUo; 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 S239914AbiAWSly (ORCPT + 99 others); Sun, 23 Jan 2022 13:41:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239902AbiAWSlI (ORCPT ); Sun, 23 Jan 2022 13:41:08 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 012D4C061765 for ; Sun, 23 Jan 2022 10:41:08 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id s2-20020a17090ad48200b001b501977b23so13568216pju.2 for ; Sun, 23 Jan 2022 10:41:07 -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=/VgvGoSrjM7RHhvz4oz6UhP4t05IzW+FafmG/hxmK+g=; b=LtksDaUoKFgi6fsMPm0LDpUgQbJ1garCGl3knzuF4lCLaZ3c+Yrsn7OJJn4xT3yZMz qsEjgH5T23Sp6vKj0Xf98AkY37c6l52KvNWIc9u+gUXjEquq5MdjBegeB3QhUjG9VeoK kHMzkjDe3KwpVy01jvSDVT4RTAFNuKoRpg9WQ+bXRSqKI7x3EREi1itGAmmnmMX9zyAb OgfvbBkheON1V3OLU/a7FTndsUWqMzFAPMeI5mkD9gnX41YSkLDgoF6gMv8ptI1H9ksB gq+VEGbDrkrXDa2G0Fs0rQSEvAOsF2abSE0i4tOqxQTeF+nuNpz4uuApyqxnnvsc2ctR mUFw== 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=/VgvGoSrjM7RHhvz4oz6UhP4t05IzW+FafmG/hxmK+g=; b=ZrxLW4dY87+plWGg5teMhR+hj2Y4dR1xeuxNvv7fd4MpmO28zgahhxxMms9P7L+W4I HHz7WvIfkMM695j2+fmmKBPNHDEYlJdbaCdQHO3wV22tgPkhQkCqQxC3GwziGt6z7UHe LVhLAvtsCHhpoI/PJigAt3bdLrBumoHbr9jrwOcarFaTps4t6YEsKuOFn4LVr0AQdJvM G8CyHBo5UMedSvpnD8FvN9DPtPZo2XsmaLT7vi+/a6QRPP6bLchTQRMx+PjTky5V1+sx Y6q/r8WFPC9CCsPsp3couLf35zQtRiLgSGwGT3ZRLss9YVtpGplEsK/DkiRjcuxNSC+x hvQw== X-Gm-Message-State: AOAM533nogohVX8ybw0z9EAsqfn6D4XLTKmUUrRomjJV0FbWO5ijAGtn UkVfNEzHIbIrUdM05wGubkE= X-Received: by 2002:a17:902:b489:b0:14a:4747:9917 with SMTP id y9-20020a170902b48900b0014a47479917mr11450174plr.26.1642963267529; Sun, 23 Jan 2022 10:41:07 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id l13sm10214049pgs.16.2022.01.23.10.41.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:41: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, linux-mm@kvack.org Subject: [PATCH 25/54] mm/vmstat: replace cpumask_weight with cpumask_empty where appropriate Date: Sun, 23 Jan 2022 10:38:56 -0800 Message-Id: <20220123183925.1052919-26-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 mm/vmstat.c code calls cpumask_weight() to check if any bit of a given cpumask is set. We can do it more efficiently with cpumask_empty() because cpumask_empty() stops traversing the cpumask as soon as it finds first set bit, while cpumask_weight() counts all bits unconditionally. Signed-off-by: Yury Norov --- mm/vmstat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/vmstat.c b/mm/vmstat.c index 4057372745d0..f56f11e3eef5 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -2035,7 +2035,7 @@ static void __init init_cpu_node_state(void) int node; for_each_online_node(node) { - if (cpumask_weight(cpumask_of_node(node)) > 0) + if (!cpumask_empty(cpumask_of_node(node))) node_set_state(node, N_CPU); } } @@ -2062,7 +2062,7 @@ static int vmstat_cpu_dead(unsigned int cpu) refresh_zone_stat_thresholds(); node_cpus = cpumask_of_node(node); - if (cpumask_weight(node_cpus) > 0) + if (!cpumask_empty(node_cpus)) return 0; node_clear_state(node, N_CPU); -- 2.30.2