From patchwork Thu Feb 10 22:49:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12742600 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 4D231C433EF for ; Thu, 10 Feb 2022 23:44:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CE3476B0073; Thu, 10 Feb 2022 18:44:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C94116B0075; Thu, 10 Feb 2022 18:44:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B0D4A6B0078; Thu, 10 Feb 2022 18:44:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0138.hostedemail.com [216.40.44.138]) by kanga.kvack.org (Postfix) with ESMTP id 9D9996B0073 for ; Thu, 10 Feb 2022 18:44:52 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 59A8590931 for ; Thu, 10 Feb 2022 23:44:52 +0000 (UTC) X-FDA: 79128502824.23.57422CF Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) by imf19.hostedemail.com (Postfix) with ESMTP id DC3A11A0002 for ; Thu, 10 Feb 2022 23:44:51 +0000 (UTC) Received: by mail-qt1-f181.google.com with SMTP id z1so7270842qto.3 for ; Thu, 10 Feb 2022 15:44:51 -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=kme7HdDPBLdZ4YQtPbT4M8C1s/pmrIz1qdi0gwByHEo=; b=Bk7rx9gKhdGsR9i8jgVS556YE2ujf0DSOvVCpTdc9PT65IOYqaQn9aot/Y9Xwof7ki cOnVYvWJbPeDast2MgmpVU8Y4Imurlc5MhQl99D0snMgl+6Gu4ehybSGgqRGOefPOoBX 5PEfm69qkAlLEYPK6MkW0jclxUqt7bd8ulqPZGiRaFYvX9dZSOUqEUCbmBDOYFYCflDj g0rF49yNULJKrkgSYVUWolWWUDbQHWS3s4jqHjk5D/DAtrm+AgzV8WvsVC9KB33nSjTz AtmQPfPBeTjUMZLE49hquJI0Dt7lAFl1HT2b050DpuOl8+hOzXAF14k5nUPeiK20UT0y Zq5Q== 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=kme7HdDPBLdZ4YQtPbT4M8C1s/pmrIz1qdi0gwByHEo=; b=Hh75WpT4+Q738pYgXOvijixW2QtEXtkUsiA0vC9bf1VGX0oxkMC2mivu2aOEMR2F2P GcwqFUpvuuzLk51kW7rUDe625vxpZnkPGLStfHGP66qb6fpE41UuRCzDPqoj2BKHc9Ca sXr5PmwsKB2h1EjV/tZZVca6DNIXIkXCVPTsLTFihChsECTVpO/z2BQJEdK3icoyS5Mc 7cL7p00rRwk0/TObt7ImxwrLldJrRT1TYETePa8dxlSCmdq8FDVs8g3F0NBF6BMB+m36 3Xco8tR/oDnx16Iqs0J9MJJBRRwRGSAO0/eGs5zU3e+tzYOdcDWqFL5C78lupMprQSWk Nikg== X-Gm-Message-State: AOAM5309T3n45WbuUGsAUwoy8VYU6SyRas7ck+fTQPmCznn2ozO8yBEj xW2iwPOuIGNFmD9xJ69rlog= X-Google-Smtp-Source: ABdhPJweRk+ewB0DrkLNcDIrsEhPbiqs1Kx+pnRXJsHT5Dn4ekm9Sd6GVVslYeAffagwYjFFuj89hQ== X-Received: by 2002:ac8:5711:: with SMTP id 17mr6533353qtw.287.1644536691131; Thu, 10 Feb 2022 15:44:51 -0800 (PST) Received: from localhost ([12.28.44.171]) by smtp.gmail.com with ESMTPSA id w10sm12500893qtj.73.2022.02.10.15.44.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 15:44:50 -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 24/49] mm/vmstat: replace cpumask_weight with cpumask_empty where appropriate Date: Thu, 10 Feb 2022 14:49:08 -0800 Message-Id: <20220210224933.379149-25-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220210224933.379149-1-yury.norov@gmail.com> References: <20220210224933.379149-1-yury.norov@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: DC3A11A0002 X-Stat-Signature: 1q9ktog6c76e1ad8pp1s5fmj7yxf86u7 X-Rspam-User: Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Bk7rx9gK; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf19.hostedemail.com: domain of yury.norov@gmail.com designates 209.85.160.181 as permitted sender) smtp.mailfrom=yury.norov@gmail.com X-HE-Tag: 1644536691-52355 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 Acked-by: Mike Rapoport --- mm/vmstat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/vmstat.c b/mm/vmstat.c index d5cc8d739fac..27a94afd4ee5 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -2041,7 +2041,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); } } @@ -2068,7 +2068,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);