Skip to content

Commit fb11a24

Browse files
Luigi RizzoThomas Gleixner
authored andcommitted
genirq: Move clear of kstat_irqs to free_desc()
desc_set_defaults() has a loop to clear the per-cpu counters kstats_irq. This is only needed in free_desc(), which is used with non-sparse IRQs so that the interrupt descriptor can be recycled. For newly allocated descriptors, the memory comes from alloc_percpu() and is already zeroed out. Move the loop to free_desc() to avoid wasting time unnecessarily. Signed-off-by: Luigi Rizzo <lrizzo@google.com> Signed-off-by: Thomas Gleixner <tglx@kernel.org> Link: https://patch.msgid.link/20260112083234.2665832-1-lrizzo@google.com
1 parent aef30c8 commit fb11a24

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

kernel/irq/irqdesc.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ static inline void free_masks(struct irq_desc *desc) { }
115115
static void desc_set_defaults(unsigned int irq, struct irq_desc *desc, int node,
116116
const struct cpumask *affinity, struct module *owner)
117117
{
118-
int cpu;
119-
120118
desc->irq_common_data.handler_data = NULL;
121119
desc->irq_common_data.msi_desc = NULL;
122120

@@ -134,8 +132,6 @@ static void desc_set_defaults(unsigned int irq, struct irq_desc *desc, int node,
134132
desc->tot_count = 0;
135133
desc->name = NULL;
136134
desc->owner = owner;
137-
for_each_possible_cpu(cpu)
138-
*per_cpu_ptr(desc->kstat_irqs, cpu) = (struct irqstat) { };
139135
desc_smp_init(desc, node, affinity);
140136
}
141137

@@ -621,9 +617,14 @@ EXPORT_SYMBOL(irq_to_desc);
621617
static void free_desc(unsigned int irq)
622618
{
623619
struct irq_desc *desc = irq_to_desc(irq);
620+
int cpu;
624621

625622
scoped_guard(raw_spinlock_irqsave, &desc->lock)
626623
desc_set_defaults(irq, desc, irq_desc_get_node(desc), NULL, NULL);
624+
625+
for_each_possible_cpu(cpu)
626+
*per_cpu_ptr(desc->kstat_irqs, cpu) = (struct irqstat) { };
627+
627628
delete_irq_desc(irq);
628629
}
629630

0 commit comments

Comments
 (0)