linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Drivers: hv: Minor cleanup around init_vp_index()
@ 2022-01-28 10:34 Vitaly Kuznetsov
  2022-01-28 10:34 ` [PATCH 1/2] Drivers: hv: Rename 'alloced' to 'allocated' Vitaly Kuznetsov
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Vitaly Kuznetsov @ 2022-01-28 10:34 UTC (permalink / raw)
  To: linux-hyperv, Wei Liu
  Cc: linux-kernel, Michael Kelley, K. Y. Srinivasan, Haiyang Zhang,
	Stephen Hemminger, Dexuan Cui

Two minor changes with no functional change intended:
- s,alloced,allocated
- compare cpumasks and not their weights

Vitaly Kuznetsov (2):
  Drivers: hv: Rename 'alloced' to 'allocated'
  Drivers: hv: Compare cpumasks and not their weights in init_vp_index()

 drivers/hv/channel_mgmt.c | 19 +++++++++----------
 drivers/hv/hyperv_vmbus.h | 14 +++++++-------
 drivers/hv/vmbus_drv.c    |  2 +-
 3 files changed, 17 insertions(+), 18 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] Drivers: hv: Rename 'alloced' to 'allocated'
  2022-01-28 10:34 [PATCH 0/2] Drivers: hv: Minor cleanup around init_vp_index() Vitaly Kuznetsov
@ 2022-01-28 10:34 ` Vitaly Kuznetsov
  2022-01-28 14:55   ` Michael Kelley (LINUX)
  2022-01-28 10:34 ` [PATCH 2/2] Drivers: hv: Compare cpumasks and not their weights in init_vp_index() Vitaly Kuznetsov
  2022-02-03 12:49 ` [PATCH 0/2] Drivers: hv: Minor cleanup around init_vp_index() Wei Liu
  2 siblings, 1 reply; 6+ messages in thread
From: Vitaly Kuznetsov @ 2022-01-28 10:34 UTC (permalink / raw)
  To: linux-hyperv, Wei Liu
  Cc: linux-kernel, Michael Kelley, K. Y. Srinivasan, Haiyang Zhang,
	Stephen Hemminger, Dexuan Cui

'Alloced' is not a real word and only saves us two letters, let's
use 'allocated' instead.

No functional change intended.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
 drivers/hv/channel_mgmt.c | 18 +++++++++---------
 drivers/hv/hyperv_vmbus.h | 14 +++++++-------
 drivers/hv/vmbus_drv.c    |  2 +-
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 60375879612f..52cf6ae525e9 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -459,7 +459,7 @@ void hv_process_channel_removal(struct vmbus_channel *channel)
 	 * init_vp_index() can (re-)use the CPU.
 	 */
 	if (hv_is_perf_channel(channel))
-		hv_clear_alloced_cpu(channel->target_cpu);
+		hv_clear_allocated_cpu(channel->target_cpu);
 
 	/*
 	 * Upon suspend, an in-use hv_sock channel is marked as "rescinded" and
@@ -728,7 +728,7 @@ static void init_vp_index(struct vmbus_channel *channel)
 	bool perf_chn = hv_is_perf_channel(channel);
 	u32 i, ncpu = num_online_cpus();
 	cpumask_var_t available_mask;
-	struct cpumask *alloced_mask;
+	struct cpumask *allocated_mask;
 	u32 target_cpu;
 	int numa_node;
 
@@ -745,7 +745,7 @@ static void init_vp_index(struct vmbus_channel *channel)
 		 */
 		channel->target_cpu = VMBUS_CONNECT_CPU;
 		if (perf_chn)
-			hv_set_alloced_cpu(VMBUS_CONNECT_CPU);
+			hv_set_allocated_cpu(VMBUS_CONNECT_CPU);
 		return;
 	}
 
@@ -760,22 +760,22 @@ static void init_vp_index(struct vmbus_channel *channel)
 				continue;
 			break;
 		}
-		alloced_mask = &hv_context.hv_numa_map[numa_node];
+		allocated_mask = &hv_context.hv_numa_map[numa_node];
 
-		if (cpumask_weight(alloced_mask) ==
+		if (cpumask_weight(allocated_mask) ==
 		    cpumask_weight(cpumask_of_node(numa_node))) {
 			/*
 			 * We have cycled through all the CPUs in the node;
-			 * reset the alloced map.
+			 * reset the allocated map.
 			 */
-			cpumask_clear(alloced_mask);
+			cpumask_clear(allocated_mask);
 		}
 
-		cpumask_xor(available_mask, alloced_mask,
+		cpumask_xor(available_mask, allocated_mask,
 			    cpumask_of_node(numa_node));
 
 		target_cpu = cpumask_first(available_mask);
-		cpumask_set_cpu(target_cpu, alloced_mask);
+		cpumask_set_cpu(target_cpu, allocated_mask);
 
 		if (channel->offermsg.offer.sub_channel_index >= ncpu ||
 		    i > ncpu || !hv_cpuself_used(target_cpu, channel))
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index 3a1f007b678a..6b45c22bb717 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -405,7 +405,7 @@ static inline bool hv_is_perf_channel(struct vmbus_channel *channel)
 	return vmbus_devs[channel->device_id].perf_device;
 }
 
-static inline bool hv_is_alloced_cpu(unsigned int cpu)
+static inline bool hv_is_allocated_cpu(unsigned int cpu)
 {
 	struct vmbus_channel *channel, *sc;
 
@@ -427,23 +427,23 @@ static inline bool hv_is_alloced_cpu(unsigned int cpu)
 	return false;
 }
 
-static inline void hv_set_alloced_cpu(unsigned int cpu)
+static inline void hv_set_allocated_cpu(unsigned int cpu)
 {
 	cpumask_set_cpu(cpu, &hv_context.hv_numa_map[cpu_to_node(cpu)]);
 }
 
-static inline void hv_clear_alloced_cpu(unsigned int cpu)
+static inline void hv_clear_allocated_cpu(unsigned int cpu)
 {
-	if (hv_is_alloced_cpu(cpu))
+	if (hv_is_allocated_cpu(cpu))
 		return;
 	cpumask_clear_cpu(cpu, &hv_context.hv_numa_map[cpu_to_node(cpu)]);
 }
 
-static inline void hv_update_alloced_cpus(unsigned int old_cpu,
+static inline void hv_update_allocated_cpus(unsigned int old_cpu,
 					  unsigned int new_cpu)
 {
-	hv_set_alloced_cpu(new_cpu);
-	hv_clear_alloced_cpu(old_cpu);
+	hv_set_allocated_cpu(new_cpu);
+	hv_clear_allocated_cpu(old_cpu);
 }
 
 #ifdef CONFIG_HYPERV_TESTING
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 17bf55fe3169..1d75a35116aa 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -1874,7 +1874,7 @@ static ssize_t target_cpu_store(struct vmbus_channel *channel,
 
 	/* See init_vp_index(). */
 	if (hv_is_perf_channel(channel))
-		hv_update_alloced_cpus(origin_cpu, target_cpu);
+		hv_update_allocated_cpus(origin_cpu, target_cpu);
 
 	/* Currently set only for storvsc channels. */
 	if (channel->change_target_cpu_callback) {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] Drivers: hv: Compare cpumasks and not their weights in init_vp_index()
  2022-01-28 10:34 [PATCH 0/2] Drivers: hv: Minor cleanup around init_vp_index() Vitaly Kuznetsov
  2022-01-28 10:34 ` [PATCH 1/2] Drivers: hv: Rename 'alloced' to 'allocated' Vitaly Kuznetsov
@ 2022-01-28 10:34 ` Vitaly Kuznetsov
  2022-01-28 14:57   ` Michael Kelley (LINUX)
  2022-02-03 12:49 ` [PATCH 0/2] Drivers: hv: Minor cleanup around init_vp_index() Wei Liu
  2 siblings, 1 reply; 6+ messages in thread
From: Vitaly Kuznetsov @ 2022-01-28 10:34 UTC (permalink / raw)
  To: linux-hyperv, Wei Liu
  Cc: linux-kernel, Michael Kelley, K. Y. Srinivasan, Haiyang Zhang,
	Stephen Hemminger, Dexuan Cui

The condition is supposed to check whether 'allocated_mask' got fully
exhausted, i.e. there's no free CPU on the NUMA node left so we have
to use one of the already used CPUs. As only bits which correspond
to CPUs from 'cpumask_of_node(numa_node)' get set in 'allocated_mask',
checking for the equal weights is technically correct but not obvious.
Let's compare cpumasks directly.

No functional change intended.

Suggested-by: Michael Kelley <mikelley@microsoft.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
 drivers/hv/channel_mgmt.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 52cf6ae525e9..26d269ba947c 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -762,8 +762,7 @@ static void init_vp_index(struct vmbus_channel *channel)
 		}
 		allocated_mask = &hv_context.hv_numa_map[numa_node];
 
-		if (cpumask_weight(allocated_mask) ==
-		    cpumask_weight(cpumask_of_node(numa_node))) {
+		if (cpumask_equal(allocated_mask, cpumask_of_node(numa_node))) {
 			/*
 			 * We have cycled through all the CPUs in the node;
 			 * reset the allocated map.
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* RE: [PATCH 1/2] Drivers: hv: Rename 'alloced' to 'allocated'
  2022-01-28 10:34 ` [PATCH 1/2] Drivers: hv: Rename 'alloced' to 'allocated' Vitaly Kuznetsov
@ 2022-01-28 14:55   ` Michael Kelley (LINUX)
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Kelley (LINUX) @ 2022-01-28 14:55 UTC (permalink / raw)
  To: vkuznets, linux-hyperv, Wei Liu
  Cc: linux-kernel, KY Srinivasan, Haiyang Zhang, Stephen Hemminger,
	Dexuan Cui

From: Vitaly Kuznetsov <vkuznets@redhat.com> Sent: Friday, January 28, 2022 2:34 AM
> 
> 'Alloced' is not a real word and only saves us two letters, let's
> use 'allocated' instead.
> 
> No functional change intended.
> 
> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> ---
>  drivers/hv/channel_mgmt.c | 18 +++++++++---------
>  drivers/hv/hyperv_vmbus.h | 14 +++++++-------
>  drivers/hv/vmbus_drv.c    |  2 +-
>  3 files changed, 17 insertions(+), 17 deletions(-)
> 

Reviewed-by: Michael Kelley <mikelley@microsoft.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH 2/2] Drivers: hv: Compare cpumasks and not their weights in init_vp_index()
  2022-01-28 10:34 ` [PATCH 2/2] Drivers: hv: Compare cpumasks and not their weights in init_vp_index() Vitaly Kuznetsov
@ 2022-01-28 14:57   ` Michael Kelley (LINUX)
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Kelley (LINUX) @ 2022-01-28 14:57 UTC (permalink / raw)
  To: vkuznets, linux-hyperv, Wei Liu
  Cc: linux-kernel, KY Srinivasan, Haiyang Zhang, Stephen Hemminger,
	Dexuan Cui

From: Vitaly Kuznetsov <vkuznets@redhat.com> Sent: Friday, January 28, 2022 2:34 AM
> 
> The condition is supposed to check whether 'allocated_mask' got fully
> exhausted, i.e. there's no free CPU on the NUMA node left so we have
> to use one of the already used CPUs. As only bits which correspond
> to CPUs from 'cpumask_of_node(numa_node)' get set in 'allocated_mask',
> checking for the equal weights is technically correct but not obvious.
> Let's compare cpumasks directly.
> 
> No functional change intended.
> 
> Suggested-by: Michael Kelley <mikelley@microsoft.com>
> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> ---
>  drivers/hv/channel_mgmt.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
> index 52cf6ae525e9..26d269ba947c 100644
> --- a/drivers/hv/channel_mgmt.c
> +++ b/drivers/hv/channel_mgmt.c
> @@ -762,8 +762,7 @@ static void init_vp_index(struct vmbus_channel *channel)
>  		}
>  		allocated_mask = &hv_context.hv_numa_map[numa_node];
> 
> -		if (cpumask_weight(allocated_mask) ==
> -		    cpumask_weight(cpumask_of_node(numa_node))) {
> +		if (cpumask_equal(allocated_mask, cpumask_of_node(numa_node)))
> {
>  			/*
>  			 * We have cycled through all the CPUs in the node;
>  			 * reset the allocated map.
> --
> 2.34.1

Reviewed-by: Michael Kelley <mikelley@microsoft.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] Drivers: hv: Minor cleanup around init_vp_index()
  2022-01-28 10:34 [PATCH 0/2] Drivers: hv: Minor cleanup around init_vp_index() Vitaly Kuznetsov
  2022-01-28 10:34 ` [PATCH 1/2] Drivers: hv: Rename 'alloced' to 'allocated' Vitaly Kuznetsov
  2022-01-28 10:34 ` [PATCH 2/2] Drivers: hv: Compare cpumasks and not their weights in init_vp_index() Vitaly Kuznetsov
@ 2022-02-03 12:49 ` Wei Liu
  2 siblings, 0 replies; 6+ messages in thread
From: Wei Liu @ 2022-02-03 12:49 UTC (permalink / raw)
  To: Vitaly Kuznetsov
  Cc: linux-hyperv, Wei Liu, linux-kernel, Michael Kelley,
	K. Y. Srinivasan, Haiyang Zhang, Stephen Hemminger, Dexuan Cui

On Fri, Jan 28, 2022 at 11:34:10AM +0100, Vitaly Kuznetsov wrote:
> Two minor changes with no functional change intended:
> - s,alloced,allocated
> - compare cpumasks and not their weights
> 
> Vitaly Kuznetsov (2):
>   Drivers: hv: Rename 'alloced' to 'allocated'
>   Drivers: hv: Compare cpumasks and not their weights in init_vp_index()

Series applied to hyperv-next. Thanks.

> 
>  drivers/hv/channel_mgmt.c | 19 +++++++++----------
>  drivers/hv/hyperv_vmbus.h | 14 +++++++-------
>  drivers/hv/vmbus_drv.c    |  2 +-
>  3 files changed, 17 insertions(+), 18 deletions(-)
> 
> -- 
> 2.34.1
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-02-03 12:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-28 10:34 [PATCH 0/2] Drivers: hv: Minor cleanup around init_vp_index() Vitaly Kuznetsov
2022-01-28 10:34 ` [PATCH 1/2] Drivers: hv: Rename 'alloced' to 'allocated' Vitaly Kuznetsov
2022-01-28 14:55   ` Michael Kelley (LINUX)
2022-01-28 10:34 ` [PATCH 2/2] Drivers: hv: Compare cpumasks and not their weights in init_vp_index() Vitaly Kuznetsov
2022-01-28 14:57   ` Michael Kelley (LINUX)
2022-02-03 12:49 ` [PATCH 0/2] Drivers: hv: Minor cleanup around init_vp_index() Wei Liu

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).