Skip to content

Commit 79eaabc

Browse files
SiFiveHollandKAGA-KOKO
authored andcommitted
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>
1 parent c475c0b commit 79eaabc

2 files changed

Lines changed: 3 additions & 9 deletions

File tree

drivers/irqchip/irq-riscv-imsic-state.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,6 @@ static void __init imsic_local_cleanup(void)
487487
lpriv = per_cpu_ptr(imsic->lpriv, cpu);
488488

489489
bitmap_free(lpriv->dirty_bitmap);
490-
kfree(lpriv->vectors);
491490
}
492491

493492
free_percpu(imsic->lpriv);
@@ -501,7 +500,8 @@ static int __init imsic_local_init(void)
501500
int cpu, i;
502501

503502
/* Allocate per-CPU private state */
504-
imsic->lpriv = alloc_percpu(typeof(*imsic->lpriv));
503+
imsic->lpriv = __alloc_percpu(struct_size(imsic->lpriv, vectors, global->nr_ids + 1),
504+
__alignof__(*imsic->lpriv));
505505
if (!imsic->lpriv)
506506
return -ENOMEM;
507507

@@ -521,12 +521,6 @@ static int __init imsic_local_init(void)
521521
timer_setup(&lpriv->timer, imsic_local_timer_callback, TIMER_PINNED);
522522
#endif
523523

524-
/* Allocate vector array */
525-
lpriv->vectors = kcalloc(global->nr_ids + 1, sizeof(*lpriv->vectors),
526-
GFP_KERNEL);
527-
if (!lpriv->vectors)
528-
goto fail_local_cleanup;
529-
530524
/* Setup vector array */
531525
for (i = 0; i <= global->nr_ids; i++) {
532526
vec = &lpriv->vectors[i];

drivers/irqchip/irq-riscv-imsic-state.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct imsic_local_priv {
4040
#endif
4141

4242
/* Local vector table */
43-
struct imsic_vector *vectors;
43+
struct imsic_vector vectors[];
4444
};
4545

4646
struct imsic_priv {

0 commit comments

Comments
 (0)