Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3309736pxb; Mon, 24 Jan 2022 07:03:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJyZT157CrnictWlruNE0P8wPQ9c/rwzeGsTqA7qY+zfuI8kvyBAOV3P5sOmECN2x++l5VAc X-Received: by 2002:aa7:918e:0:b0:4c6:8684:68e9 with SMTP id x14-20020aa7918e000000b004c6868468e9mr14408188pfa.37.1643036617043; Mon, 24 Jan 2022 07:03:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643036617; cv=none; d=google.com; s=arc-20160816; b=g1fOw719pXg1Qo6HoT2rpwpTC/U1nhVJarwLuiPfYFPi5VdtxvD87HYKvV2iKxJJxT 87RqBxaV10ZCYw7fz8/ppld+ADDCkeFb9xf3TBXPinB5mY4VRbOszylg00Esyz6B0L86 m6lkefIAerW0QpL336dZiRRrQdj/yopbYLWI+G1b/MJi/9tbbXOKtiE+l8yoFhx3sQ8e XLAGE38cImGmAFBKcujQz2amUxlLZfGCHxOpwjrs2xraS1ftamCRIQ+qBmjhSrBfPzom 2Ih/NJ4kD2vdeDZzLizc6HODdX4Ce9ig/4DvZCQqQf3iauJMbfSlJ/4S/3jLnv018gbB k8Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=vokrEqgH7DKy8+Sb3Tc3TLbG6Gi3mHbYVlUxj/zaD50=; b=mb/1XNFcERLmEJbZEt0JAeNBuYfzS++aEJeN0SARuRESotymiUd+s3kDy3A3UEh+rQ qeCzPVd6FXpBBFXGcoYMRre08mQMuRVaquun45MOoNY66Az4rtSseCxJA/gEgSMu7gVc Loi1gV9IFyTQp1OKn9uCJEnjDQFku9YP2wZ47uB8Q1IsudJpl+HgRZPv9IxYtefIKThD lAtxKLEa1IsPyP7dL6JTt/1Yl5l1SK5pFgcoNWAVbmRAJ4GX63v3o9ylEQJr3D4rQJeJ qotjCrvImfED34Mry0KN862bVzD7fzLstBVkiFvVzpWbEPZK1VC27mAnxs8BgAbdBphr bnpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KAI8PcRr; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i4si12422718pfr.238.2022.01.24.07.03.05; Mon, 24 Jan 2022 07:03:37 -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=@kernel.org header.s=k20201202 header.b=KAI8PcRr; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240537AbiAXAHi (ORCPT + 99 others); Sun, 23 Jan 2022 19:07:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240530AbiAXAHg (ORCPT ); Sun, 23 Jan 2022 19:07:36 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7946C06173B; Sun, 23 Jan 2022 16:07:35 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 66A0861219; Mon, 24 Jan 2022 00:07:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9258C340E3; Mon, 24 Jan 2022 00:07:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642982854; bh=sOPV0ZX6vJ/xD8yptJMnME9m2gNuPb3oT/LNhk3LgiI=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=KAI8PcRr1KyEztG8DepJx/ckB7OmvLi1qrVhpOp3/WMkpHXIBJpxdWLRqVKFUWTmg fTNYjzlHcqPd9JhD6vvU760g0EkpHWsw9gx1/uYXg4QtwPlQpXG/CNZHW9CJlFvBVN fk/VXGpL6FU+IuCOKXQ23TXn4nuyCPnffUIyxMHFx5FmqN3/jkGkT25J8EqDp6QgnJ +TKyRMhYTK33qNlWxHPcRMU8keav1O+fIQxcTs/Mu410yi6/sRm9PhJnD9bDHHSnuf XihQ9mxR3gCCxoKP475YBQ+3wPsusnEPkl4kB7CkDf5j1j7ExDOhDSOYAqEpWSxoed U38BtFmEEuhYA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 7D9045C044F; Sun, 23 Jan 2022 16:07:34 -0800 (PST) Date: Sun, 23 Jan 2022 16:07:34 -0800 From: "Paul E. McKenney" To: Yury Norov Cc: Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?utf-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= , 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, Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Joel Fernandes , rcu@vger.kernel.org Subject: Re: [PATCH 22/54] rcu: replace cpumask_weight with cpumask_empty where appropriate Message-ID: <20220124000734.GB4285@paulmck-ThinkPad-P17-Gen-1> Reply-To: paulmck@kernel.org References: <20220123183925.1052919-1-yury.norov@gmail.com> <20220123183925.1052919-23-yury.norov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220123183925.1052919-23-yury.norov@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jan 23, 2022 at 10:38:53AM -0800, Yury Norov wrote: > 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 Good point! Queued and pushed, thank you! Thanx, Paul > --- > 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 >