linux-hyperv.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: "Michael Kelley (LINUX)" <mikelley@microsoft.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" <linux-kernel@vger.kernel.org>,
	"KY 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" <linux-hyperv@vger.kernel.org>,
	"Yury Norov" <yury.norov@gmail.com>
Subject: RE: [PATCH 43/54] drivers/hv: replace cpumask_weight with cpumask_weight_eq
Date: Fri, 28 Jan 2022 10:31:52 +0100	[thread overview]
Message-ID: <8735l8gq9j.fsf@redhat.com> (raw)
In-Reply-To: <MWHPR21MB1593C8511E18E4539CECAEC5D7219@MWHPR21MB1593.namprd21.prod.outlook.com>

"Michael Kelley (LINUX)" <mikelley@microsoft.com> writes:

> From: Vitaly Kuznetsov <vkuznets@redhat.com> Sent: Monday, January 24, 2022 1:20 AM
>> 
>> Yury Norov <yury.norov@gmail.com> writes:
>> 
...
>> >
>> > 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.
>> 
> I agree with Vitaly in preferring the old version, and indeed performance
> here is a shrug.  But actually, I think the old version is a poorly coded way
> to determine if the two cpumasks are equal. The following would correctly
> capture the intent:
>
> 	if (cpumask_equal(alloced_mask, cpumask_of_node(numa_node))
>

Indeed. While it seems that only CPUs from 'cpumask_of_node(numa_node)'
can be set in 'alloced_mask' (and thus the comparison is valid), there's
no real need to weigh anything. I'll send a patch.

-- 
Vitaly


      reply	other threads:[~2022-01-28  9:32 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
2022-01-27 15:02     ` Michael Kelley (LINUX)
2022-01-28  9:31       ` Vitaly Kuznetsov [this message]

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=8735l8gq9j.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=mikelley@microsoft.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).