From patchwork Sun Jan 23 18:38:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12721098 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BE9BC433F5 for ; Sun, 23 Jan 2022 18:41:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 885D56B0081; Sun, 23 Jan 2022 13:41:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 833216B0083; Sun, 23 Jan 2022 13:41:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6FA0B6B0085; Sun, 23 Jan 2022 13:41:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0123.hostedemail.com [216.40.44.123]) by kanga.kvack.org (Postfix) with ESMTP id 5E5546B0081 for ; Sun, 23 Jan 2022 13:41:09 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 16E7B9367B for ; Sun, 23 Jan 2022 18:41:09 +0000 (UTC) X-FDA: 79062419058.07.8A86B4D Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by imf01.hostedemail.com (Postfix) with ESMTP id 7F1014001A for ; Sun, 23 Jan 2022 18:41:08 +0000 (UTC) Received: by mail-pj1-f49.google.com with SMTP id w12-20020a17090a528c00b001b276aa3aabso18609851pjh.0 for ; Sun, 23 Jan 2022 10:41: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=/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=38qD+qt6sWywWVV5V0lccasdXe+b6ytItfnKzEOOHlWZ6ZZFur90bv6R36WQVArv7w vJo2MWdfHnKp+iq1NjB7bOTtt3KsU/GttNCjDGYDYZO2xU3+hg7iOkithJTfg2Xe3hk/ 2/JzqnHqkVvX7U1XdlwmV4u/Atsr9NL2hmlmesG1ndK/0ZLGYSETxq4I/P9eGWNitZAi K/s3EGMfhWRkF6EyfLeeUjGlr/V7c52GfkpaNSYiw/SwEiuUIaHcRoU6yofvw4A97NmD yNVzUwN4s5OT910hvK+uJtsYnInSnRBMtP0Jv39QxWx6LnnnOMy3YWAXx2/elgSKi5jn wPig== X-Gm-Message-State: AOAM530c3F3BMyThf8fDNHcFQB3m8sbrmKAxrD3IqjyJkwytglL/w4iH quigUyg4eipwL261ztp7qCU= X-Google-Smtp-Source: ABdhPJxM5+OvTM7zV5jkK8eH28BzzoNvH/Nv9KCuB2FTZ9Fcl9QZ0o8NEWTqi1guXckSoVXq6LTshg== 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?b?TWljaGHFgiBNaXJvc8WC?= =?utf-8?b?YXc=?= , 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 X-Rspam-User: nil X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 7F1014001A X-Stat-Signature: xjjjospgozkytr5d9iocqfa97o1tw3se Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=LtksDaUo; spf=pass (imf01.hostedemail.com: domain of yury.norov@gmail.com designates 209.85.216.49 as permitted sender) smtp.mailfrom=yury.norov@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1642963268-102578 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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);