Linux-HyperV List
 help / color / mirror / Atom feed
* [PATCH 1/1] Drivers: hv: vmbus: Simplify allocation of vmbus_evt
@ 2026-02-18 17:01 Michael Kelley
  2026-02-18 21:52 ` [EXTERNAL] " Long Li
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Kelley @ 2026-02-18 17:01 UTC (permalink / raw)
  To: kys, haiyangz, wei.liu, decui, longli, linux-hyperv; +Cc: linux-kernel

From: Michael Kelley <mhklinux@outlook.com>

The per-cpu variable vmbus_evt is currently dynamically allocated. It's
only 8 bytes, so just allocate it statically to simplify and save a few
lines of code.

Signed-off-by: Michael Kelley <mhklinux@outlook.com>
---
 drivers/hv/vmbus_drv.c | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 97dfa529d250..2219ce41b384 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -51,7 +51,7 @@ static struct device  *vmbus_root_device;
 
 static int hyperv_cpuhp_online;
 
-static long __percpu *vmbus_evt;
+static DEFINE_PER_CPU(long, vmbus_evt);
 
 /* Values parsed from ACPI DSDT */
 int vmbus_irq;
@@ -1475,13 +1475,11 @@ static int vmbus_bus_init(void)
 	if (vmbus_irq == -1) {
 		hv_setup_vmbus_handler(vmbus_isr);
 	} else {
-		vmbus_evt = alloc_percpu(long);
 		ret = request_percpu_irq(vmbus_irq, vmbus_percpu_isr,
-				"Hyper-V VMbus", vmbus_evt);
+				"Hyper-V VMbus", &vmbus_evt);
 		if (ret) {
 			pr_err("Can't request Hyper-V VMbus IRQ %d, Err %d",
 					vmbus_irq, ret);
-			free_percpu(vmbus_evt);
 			goto err_setup;
 		}
 	}
@@ -1510,12 +1508,10 @@ static int vmbus_bus_init(void)
 	return 0;
 
 err_connect:
-	if (vmbus_irq == -1) {
+	if (vmbus_irq == -1)
 		hv_remove_vmbus_handler();
-	} else {
-		free_percpu_irq(vmbus_irq, vmbus_evt);
-		free_percpu(vmbus_evt);
-	}
+	else
+		free_percpu_irq(vmbus_irq, &vmbus_evt);
 err_setup:
 	bus_unregister(&hv_bus);
 	return ret;
@@ -2981,12 +2977,11 @@ static void __exit vmbus_exit(void)
 	vmbus_connection.conn_state = DISCONNECTED;
 	hv_stimer_global_cleanup();
 	vmbus_disconnect();
-	if (vmbus_irq == -1) {
+	if (vmbus_irq == -1)
 		hv_remove_vmbus_handler();
-	} else {
-		free_percpu_irq(vmbus_irq, vmbus_evt);
-		free_percpu(vmbus_evt);
-	}
+	else
+		free_percpu_irq(vmbus_irq, &vmbus_evt);
+
 	for_each_online_cpu(cpu) {
 		struct hv_per_cpu_context *hv_cpu
 			= per_cpu_ptr(hv_context.cpu_context, cpu);
-- 
2.25.1


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

* RE: [EXTERNAL] [PATCH 1/1] Drivers: hv: vmbus: Simplify allocation of vmbus_evt
  2026-02-18 17:01 [PATCH 1/1] Drivers: hv: vmbus: Simplify allocation of vmbus_evt Michael Kelley
@ 2026-02-18 21:52 ` Long Li
  2026-02-18 23:47   ` Wei Liu
  0 siblings, 1 reply; 4+ messages in thread
From: Long Li @ 2026-02-18 21:52 UTC (permalink / raw)
  To: mhklinux@outlook.com, KY Srinivasan, Haiyang Zhang,
	wei.liu@kernel.org, Dexuan Cui, linux-hyperv@vger.kernel.org
  Cc: linux-kernel@vger.kernel.org

> From: Michael Kelley <mhklinux@outlook.com>
> 
> The per-cpu variable vmbus_evt is currently dynamically allocated. It's only 8
> bytes, so just allocate it statically to simplify and save a few lines of code.
> 
> Signed-off-by: Michael Kelley <mhklinux@outlook.com>

Reviewed-by: Long Li <longli@microsoft.com>

> ---
>  drivers/hv/vmbus_drv.c | 23 +++++++++--------------
>  1 file changed, 9 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index
> 97dfa529d250..2219ce41b384 100644
> --- a/drivers/hv/vmbus_drv.c
> +++ b/drivers/hv/vmbus_drv.c
> @@ -51,7 +51,7 @@ static struct device  *vmbus_root_device;
> 
>  static int hyperv_cpuhp_online;
> 
> -static long __percpu *vmbus_evt;
> +static DEFINE_PER_CPU(long, vmbus_evt);
> 
>  /* Values parsed from ACPI DSDT */
>  int vmbus_irq;
> @@ -1475,13 +1475,11 @@ static int vmbus_bus_init(void)
>         if (vmbus_irq == -1) {
>                 hv_setup_vmbus_handler(vmbus_isr);
>         } else {
> -               vmbus_evt = alloc_percpu(long);
>                 ret = request_percpu_irq(vmbus_irq, vmbus_percpu_isr,
> -                               "Hyper-V VMbus", vmbus_evt);
> +                               "Hyper-V VMbus", &vmbus_evt);
>                 if (ret) {
>                         pr_err("Can't request Hyper-V VMbus IRQ %d, Err %d",
>                                         vmbus_irq, ret);
> -                       free_percpu(vmbus_evt);
>                         goto err_setup;
>                 }
>         }
> @@ -1510,12 +1508,10 @@ static int vmbus_bus_init(void)
>         return 0;
> 
>  err_connect:
> -       if (vmbus_irq == -1) {
> +       if (vmbus_irq == -1)
>                 hv_remove_vmbus_handler();
> -       } else {
> -               free_percpu_irq(vmbus_irq, vmbus_evt);
> -               free_percpu(vmbus_evt);
> -       }
> +       else
> +               free_percpu_irq(vmbus_irq, &vmbus_evt);
>  err_setup:
>         bus_unregister(&hv_bus);
>         return ret;
> @@ -2981,12 +2977,11 @@ static void __exit vmbus_exit(void)
>         vmbus_connection.conn_state = DISCONNECTED;
>         hv_stimer_global_cleanup();
>         vmbus_disconnect();
> -       if (vmbus_irq == -1) {
> +       if (vmbus_irq == -1)
>                 hv_remove_vmbus_handler();
> -       } else {
> -               free_percpu_irq(vmbus_irq, vmbus_evt);
> -               free_percpu(vmbus_evt);
> -       }
> +       else
> +               free_percpu_irq(vmbus_irq, &vmbus_evt);
> +
>         for_each_online_cpu(cpu) {
>                 struct hv_per_cpu_context *hv_cpu
>                         = per_cpu_ptr(hv_context.cpu_context, cpu);
> --
> 2.25.1


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

* Re: [EXTERNAL] [PATCH 1/1] Drivers: hv: vmbus: Simplify allocation of vmbus_evt
  2026-02-18 21:52 ` [EXTERNAL] " Long Li
@ 2026-02-18 23:47   ` Wei Liu
  2026-02-19  0:33     ` Michael Kelley
  0 siblings, 1 reply; 4+ messages in thread
From: Wei Liu @ 2026-02-18 23:47 UTC (permalink / raw)
  To: Long Li
  Cc: mhklinux@outlook.com, KY Srinivasan, Haiyang Zhang,
	wei.liu@kernel.org, Dexuan Cui, linux-hyperv@vger.kernel.org,
	linux-kernel@vger.kernel.org

On Wed, Feb 18, 2026 at 09:52:41PM +0000, Long Li wrote:
> > From: Michael Kelley <mhklinux@outlook.com>
> > 
> > The per-cpu variable vmbus_evt is currently dynamically allocated. It's only 8
> > bytes, so just allocate it statically to simplify and save a few lines of code.
> > 
> > Signed-off-by: Michael Kelley <mhklinux@outlook.com>
> 
> Reviewed-by: Long Li <longli@microsoft.com>

Applied to hyperv-next.

This has a conflict with Jan Kiszka's patch. It is easy to resolve.
Please check and shout if something is off.

Wei

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

* RE: [EXTERNAL] [PATCH 1/1] Drivers: hv: vmbus: Simplify allocation of vmbus_evt
  2026-02-18 23:47   ` Wei Liu
@ 2026-02-19  0:33     ` Michael Kelley
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Kelley @ 2026-02-19  0:33 UTC (permalink / raw)
  To: Wei Liu, Long Li
  Cc: KY Srinivasan, Haiyang Zhang, Dexuan Cui,
	linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org

From: Wei Liu <wei.liu@kernel.org>
> 
> On Wed, Feb 18, 2026 at 09:52:41PM +0000, Long Li wrote:
> > > From: Michael Kelley <mhklinux@outlook.com>
> > >
> > > The per-cpu variable vmbus_evt is currently dynamically allocated. It's only 8
> > > bytes, so just allocate it statically to simplify and save a few lines of code.
> > >
> > > Signed-off-by: Michael Kelley <mhklinux@outlook.com>
> >
> > Reviewed-by: Long Li <longli@microsoft.com>
> 
> Applied to hyperv-next.
> 
> This has a conflict with Jan Kiszka's patch. It is easy to resolve.
> Please check and shout if something is off.
> 

Thanks. The conflict resolution looks good to me.

Michael

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

end of thread, other threads:[~2026-02-19  0:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-18 17:01 [PATCH 1/1] Drivers: hv: vmbus: Simplify allocation of vmbus_evt Michael Kelley
2026-02-18 21:52 ` [EXTERNAL] " Long Li
2026-02-18 23:47   ` Wei Liu
2026-02-19  0:33     ` Michael Kelley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox