mirror of
https://github.com/torvalds/linux.git
synced 2026-01-25 07:47:50 +00:00
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:
committed by
Thomas Gleixner
parent
c475c0b713
commit
79eaabc61d
@@ -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];
|
||||
|
||||
@@ -40,7 +40,7 @@ struct imsic_local_priv {
|
||||
#endif
|
||||
|
||||
/* Local vector table */
|
||||
struct imsic_vector *vectors;
|
||||
struct imsic_vector vectors[];
|
||||
};
|
||||
|
||||
struct imsic_priv {
|
||||
|
||||
Reference in New Issue
Block a user