irqchip/riscv-imsic: Embed the vector array in lpriv

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>
This commit is contained in:
Samuel Holland
2025-10-15 12:55:13 -07:00
committed by Thomas Gleixner
parent c475c0b713
commit 79eaabc61d
2 changed files with 3 additions and 9 deletions

View 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];

View File

@@ -40,7 +40,7 @@ struct imsic_local_priv {
#endif
/* Local vector table */
struct imsic_vector *vectors;
struct imsic_vector vectors[];
};
struct imsic_priv {