From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: Yury Norov <yury.norov@gmail.com>
Cc: "Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
"Rasmus Villemoes" <linux@rasmusvillemoes.dk>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Michał Mirosław" <mirq-linux@rere.qmqm.pl>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Peter Zijlstra" <peterz@infradead.org>,
"David Laight" <David.Laight@aculab.com>,
"Joe Perches" <joe@perches.com>,
"Dennis Zhou" <dennis@kernel.org>,
"Emil Renner Berthing" <kernel@esmil.dk>,
"Nicholas Piggin" <npiggin@gmail.com>,
"Matti Vaittinen" <matti.vaittinen@fi.rohmeurope.com>,
"Alexey Klimov" <aklimov@redhat.com>,
linux-kernel@vger.kernel.org,
"K. Y. Srinivasan" <kys@microsoft.com>,
"Haiyang Zhang" <haiyangz@microsoft.com>,
"Stephen Hemminger" <sthemmin@microsoft.com>,
"Wei Liu" <wei.liu@kernel.org>,
"Dexuan Cui" <decui@microsoft.com>,
linux-hyperv@vger.kernel.org
Subject: Re: [PATCH 43/54] drivers/hv: replace cpumask_weight with cpumask_weight_eq
Date: Mon, 24 Jan 2022 10:20:13 +0100 [thread overview]
Message-ID: <87sftdij76.fsf@redhat.com> (raw)
In-Reply-To: <20220123183925.1052919-44-yury.norov@gmail.com>
Yury Norov <yury.norov@gmail.com> writes:
> init_vp_index() calls cpumask_weight() to compare the weights of cpumasks
> We can do it more efficiently with cpumask_weight_eq because conditional
> cpumask_weight may stop traversing the cpumask earlier (at least one), as
> soon as condition is met.
Same comment as for "PATCH 41/54": cpumask_weight_eq() can only stop
earlier if the condition is not met, to prove the equality all bits need
always have to be examined.
>
> Signed-off-by: Yury Norov <yury.norov@gmail.com>
> ---
> drivers/hv/channel_mgmt.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
> index 60375879612f..7420a5fd47b5 100644
> --- a/drivers/hv/channel_mgmt.c
> +++ b/drivers/hv/channel_mgmt.c
> @@ -762,8 +762,8 @@ static void init_vp_index(struct vmbus_channel *channel)
> }
> alloced_mask = &hv_context.hv_numa_map[numa_node];
>
> - if (cpumask_weight(alloced_mask) ==
> - cpumask_weight(cpumask_of_node(numa_node))) {
> + if (cpumask_weight_eq(alloced_mask,
> + cpumask_weight(cpumask_of_node(numa_node)))) {
This code is not performace critical and I prefer the old version:
cpumask_weight() == cpumask_weight()
looks better than
cpumask_weight_eq(..., cpumask_weight())
(let alone the inner cpumask_of_node()) to me.
> /*
> * We have cycled through all the CPUs in the node;
> * reset the alloced map.
--
Vitaly
next prev parent reply other threads:[~2022-01-24 9:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20220123183925.1052919-1-yury.norov@gmail.com>
2022-01-23 18:39 ` [PATCH 43/54] drivers/hv: replace cpumask_weight with cpumask_weight_eq Yury Norov
2022-01-23 22:00 ` Wei Liu
2022-01-23 22:02 ` Haiyang Zhang
2022-01-24 9:20 ` Vitaly Kuznetsov [this message]
2022-01-27 15:02 ` Michael Kelley (LINUX)
2022-01-28 9:31 ` Vitaly Kuznetsov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87sftdij76.fsf@redhat.com \
--to=vkuznets@redhat.com \
--cc=David.Laight@aculab.com \
--cc=aklimov@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=decui@microsoft.com \
--cc=dennis@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=haiyangz@microsoft.com \
--cc=joe@perches.com \
--cc=kernel@esmil.dk \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=matti.vaittinen@fi.rohmeurope.com \
--cc=mirq-linux@rere.qmqm.pl \
--cc=npiggin@gmail.com \
--cc=peterz@infradead.org \
--cc=sthemmin@microsoft.com \
--cc=wei.liu@kernel.org \
--cc=yury.norov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).