]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
irqchip/riscv-imsic: Embed the vector array in lpriv
authorSamuel Holland <samuel.holland@sifive.com>
Wed, 15 Oct 2025 19:55:13 +0000 (12:55 -0700)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 16 Oct 2025 16:17:28 +0000 (18:17 +0200)
Reduce pointer chasing and the number of allocations by using a flexible
array member for the vector array instead of a separate allocation.

Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
drivers/irqchip/irq-riscv-imsic-state.c
drivers/irqchip/irq-riscv-imsic-state.h

index dc95ad856d80adc536c89479bdf2a11c80e8ea63..9a499efdebe3639f1ed8d8bbcf10cf312b326374 100644 (file)
@@ -487,7 +487,6 @@ static void __init imsic_local_cleanup(void)
                lpriv = per_cpu_ptr(imsic->lpriv, cpu);
 
                bitmap_free(lpriv->dirty_bitmap);
-               kfree(lpriv->vectors);
        }
 
        free_percpu(imsic->lpriv);
@@ -501,7 +500,8 @@ static int __init imsic_local_init(void)
        int cpu, i;
 
        /* Allocate per-CPU private state */
-       imsic->lpriv = alloc_percpu(typeof(*imsic->lpriv));
+       imsic->lpriv = __alloc_percpu(struct_size(imsic->lpriv, vectors, global->nr_ids + 1),
+                                     __alignof__(*imsic->lpriv));
        if (!imsic->lpriv)
                return -ENOMEM;
 
@@ -521,12 +521,6 @@ static int __init imsic_local_init(void)
                timer_setup(&lpriv->timer, imsic_local_timer_callback, TIMER_PINNED);
 #endif
 
-               /* Allocate vector array */
-               lpriv->vectors = kcalloc(global->nr_ids + 1, sizeof(*lpriv->vectors),
-                                        GFP_KERNEL);
-               if (!lpriv->vectors)
-                       goto fail_local_cleanup;
-
                /* Setup vector array */
                for (i = 0; i <= global->nr_ids; i++) {
                        vec = &lpriv->vectors[i];
index 57f951952b0c8b9bc31e37e378dc127f051ed756..196457f1bbca62ce0b54eb0e4eaced255a77d869 100644 (file)
@@ -40,7 +40,7 @@ struct imsic_local_priv {
 #endif
 
        /* Local vector table */
-       struct imsic_vector                     *vectors;
+       struct imsic_vector                     vectors[];
 };
 
 struct imsic_priv {