RE: [EXTERNAL] [PATCH 1/1] Drivers: hv: vmbus: Simplify allocation of vmbus_evt
From: Long Li
Date: Wed Feb 18 2026 - 16:52:53 EST
> From: Michael Kelley <mhklinux@xxxxxxxxxxx>
>
> 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@xxxxxxxxxxx>
Reviewed-by: Long Li <longli@xxxxxxxxxxxxx>
> ---
> 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