Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3175030pxb; Mon, 24 Jan 2022 04:14:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJwNPJpt9cwuAr60obMcrO99koMuAzJvfKPXFcvKs8B7xOdMJX7YljYnyTmeZGFI5XGHnz0F X-Received: by 2002:a17:903:2310:b0:14b:60d5:9354 with SMTP id d16-20020a170903231000b0014b60d59354mr1783037plh.70.1643026466953; Mon, 24 Jan 2022 04:14:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643026466; cv=none; d=google.com; s=arc-20160816; b=lM2Wlo2ZKC/KxAhSlDgTqlm1n+tdOp4R55Tuypw1WPs88/dej0C3UZMgcIfe/vPyIU PfUhsySUn7xjUN2aMX0r0BYJY58+7iaDvkdBqWJBR/fN+WYyCnZTmLK2Gkd3oqeUZEi/ ee/VZf+CGg/SntfPRDJe6zl5REWB7WLsYJ27lvUcOUdApqYpLjZsj32zZC7/7+SajyFB JtGWVcF9iuMlGUv+Efqd1Ej5IS/QaTQFsDwTpenpuINc/UHk4IhEwj3ynMmELwYrGiZA PQ5PrB8s5GE3euxYO5Jqb1WrolpGYf+/aGtwq4y9ghI9Bhkc8obq7jrvGeRBMG4iYIfK 1aGA== 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=UUKJUI5LEQZKArKXE5kTNrLEuODfkVdvxUFHk4GiAXc=; b=tfhqdEB9rOQNo7G0jm1b6+lJCDmesgHkYWHf+3B6vk0VKUW4ixY68LRGNMY8bi5+LH FUFHU1/VstAsGJFmM+UupTkGpNWPuSbTQdm1Y0kwsJGW/B+OVCp1LsyA2HAAFCpF7GUw SJfgsDn6DzFlKwF57o1mHBRU2yw+YSAmuWgh6bL3ir7uiv6Tb890v3C2vusJvpcHtL7p UAgUbc/ikeoAt6Dh4arnUTEAG9bZ0/UjI/+aptwmri69US2yrHQZE/dMn8Lu3w5ELXes //DuDr6gLmS3W+HwfOYhRSHj64MBJRPipQHLi7l0YD3IE3+5604hbMXKdMoDHx/SFeBB STqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=B8p8tHIZ; 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 q207si1090434pfc.305.2022.01.24.04.14.13; Mon, 24 Jan 2022 04:14:26 -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=B8p8tHIZ; 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 S240039AbiAWSlh (ORCPT + 99 others); Sun, 23 Jan 2022 13:41:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239715AbiAWSk6 (ORCPT ); Sun, 23 Jan 2022 13:40:58 -0500 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9CD8C06173D; Sun, 23 Jan 2022 10:40:57 -0800 (PST) Received: by mail-pg1-x533.google.com with SMTP id v3so7873287pgc.1; Sun, 23 Jan 2022 10:40:57 -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=UUKJUI5LEQZKArKXE5kTNrLEuODfkVdvxUFHk4GiAXc=; b=B8p8tHIZv+dHEfVHl/No8uGC1d6rBNR6KHiGIhB03BC1EQYyDbAFs0hZR8USDjt7YJ 3BoLtDJ5s3uk+CrF8kCmGokKb4I5AxPFFEYJNS2upRFlOrifOivmrVCyvvbSblPt+8QR STKpfwVdgogy51f2LObUIq3MF8dfBcNvricle3FbVfD/Lvk9zeg90qAhFoz9FJ7BxJn/ GM/zJCtI9FWyBo11QplwdknQKRo4mmbbO9dcmA2AMQ2r6h4D/R+C/6Z5Upz2H+6FwawR McHv69WPqBt6COW7wuNPvTYLatkej8o2lExGiIEITYQDhZ07nISE4qjY1T0p/V3fyJXa +iXQ== 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=UUKJUI5LEQZKArKXE5kTNrLEuODfkVdvxUFHk4GiAXc=; b=jY6QJ0zklMjv6hqzQGgfMJMWOCj1OigQws7E2DIA7QIF+ywjUYshnSxbkppqTHE3qz ScCBrRuokyUfDZMjMN5T7I0g+KONAI80+lxu8dAaJhGRzqCo5NhXwXc1VLAbWwmhgG/P r4Dtkj41jH/eVcDFBllI9CQwipw8lSGLyowygGsCzeoIe1jT3LNJRfBmHfNORmvxwh9c a1BFTwexAsZB3PV19KuKua5yMLMI8I8UggvxwdE4/YVNnko5FtjlBKoa4DKik8nRd16c VvsvL1ftk162yIXQJs5cLIT6pultr5ev6P2cI+7pm/78TKZLKybboKJdbfRI+rA827kE amgA== X-Gm-Message-State: AOAM532F9vb8toge0AiG3g2TZ0YM8o98ji3alqL8g5kVrTlUWNEshQDb VNuIJ1rPp1Wnk1bBwKfzWuQOPpfls9U= X-Received: by 2002:a62:dd56:0:b0:4c7:8603:3ffe with SMTP id w83-20020a62dd56000000b004c786033ffemr8567637pff.15.1642963257316; Sun, 23 Jan 2022 10:40:57 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id v8sm3258809pfu.186.2022.01.23.10.40.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:40:57 -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, "Paul E. McKenney" , Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Joel Fernandes , rcu@vger.kernel.org Subject: [PATCH 22/54] rcu: replace cpumask_weight with cpumask_empty where appropriate Date: Sun, 23 Jan 2022 10:38:53 -0800 Message-Id: <20220123183925.1052919-23-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, RCU 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 --- kernel/rcu/tree_nocb.h | 4 ++-- kernel/rcu/tree_plugin.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h index eeafb546a7a0..f83c7b1d6110 100644 --- a/kernel/rcu/tree_nocb.h +++ b/kernel/rcu/tree_nocb.h @@ -1169,7 +1169,7 @@ void __init rcu_init_nohz(void) struct rcu_data *rdp; #if defined(CONFIG_NO_HZ_FULL) - if (tick_nohz_full_running && cpumask_weight(tick_nohz_full_mask)) + if (tick_nohz_full_running && !cpumask_empty(tick_nohz_full_mask)) need_rcu_nocb_mask = true; #endif /* #if defined(CONFIG_NO_HZ_FULL) */ @@ -1348,7 +1348,7 @@ static void __init rcu_organize_nocb_kthreads(void) */ void rcu_bind_current_to_nocb(void) { - if (cpumask_available(rcu_nocb_mask) && cpumask_weight(rcu_nocb_mask)) + if (cpumask_available(rcu_nocb_mask) && !cpumask_empty(rcu_nocb_mask)) WARN_ON(sched_setaffinity(current->pid, rcu_nocb_mask)); } EXPORT_SYMBOL_GPL(rcu_bind_current_to_nocb); diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h index c5b45c2f68a1..0dc0c8d6717c 100644 --- a/kernel/rcu/tree_plugin.h +++ b/kernel/rcu/tree_plugin.h @@ -1215,7 +1215,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu) cpu != outgoingcpu) cpumask_set_cpu(cpu, cm); cpumask_and(cm, cm, housekeeping_cpumask(HK_FLAG_RCU)); - if (cpumask_weight(cm) == 0) + if (cpumask_empty(cm)) cpumask_copy(cm, housekeeping_cpumask(HK_FLAG_RCU)); set_cpus_allowed_ptr(t, cm); free_cpumask_var(cm); -- 2.30.2