lkml.org 
[lkml]   [2022]   [Jan]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH 43/54] drivers/hv: replace cpumask_weight with cpumask_weight_eq
Date


> -----Original Message-----
> From: Yury Norov <yury.norov@gmail.com>
> Sent: Sunday, January 23, 2022 1:39 PM
> To: Yury Norov <yury.norov@gmail.com>; 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; 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
> Subject: [PATCH 43/54] drivers/hv: replace cpumask_weight with cpumask_weight_eq
>
> 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.
>
> 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)))) {
> /*
> * We have cycled through all the CPUs in the node;
> * reset the alloced map.

Thanks.

Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>

\
 
 \ /
  Last update: 2022-01-23 23:02    [W:1.145 / U:0.120 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site