]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
genirq: Move clear of kstat_irqs to free_desc()
authorLuigi Rizzo <lrizzo@google.com>
Mon, 12 Jan 2026 08:32:33 +0000 (08:32 +0000)
committerThomas Gleixner <tglx@kernel.org>
Tue, 13 Jan 2026 09:16:29 +0000 (10:16 +0100)
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
kernel/irq/irqdesc.c

index f8e4e13dbe33965b8ede1872515596eb64dfdb74..c3bc00e08c58bb8ae7c4b8c17090d66b720253b9 100644 (file)
@@ -115,8 +115,6 @@ static inline void free_masks(struct irq_desc *desc) { }
 static void desc_set_defaults(unsigned int irq, struct irq_desc *desc, int node,
                              const struct cpumask *affinity, struct module *owner)
 {
-       int cpu;
-
        desc->irq_common_data.handler_data = NULL;
        desc->irq_common_data.msi_desc = NULL;
 
@@ -134,8 +132,6 @@ static void desc_set_defaults(unsigned int irq, struct irq_desc *desc, int node,
        desc->tot_count = 0;
        desc->name = NULL;
        desc->owner = owner;
-       for_each_possible_cpu(cpu)
-               *per_cpu_ptr(desc->kstat_irqs, cpu) = (struct irqstat) { };
        desc_smp_init(desc, node, affinity);
 }
 
@@ -621,9 +617,14 @@ EXPORT_SYMBOL(irq_to_desc);
 static void free_desc(unsigned int irq)
 {
        struct irq_desc *desc = irq_to_desc(irq);
+       int cpu;
 
        scoped_guard(raw_spinlock_irqsave, &desc->lock)
                desc_set_defaults(irq, desc, irq_desc_get_node(desc), NULL, NULL);
+
+       for_each_possible_cpu(cpu)
+               *per_cpu_ptr(desc->kstat_irqs, cpu) = (struct irqstat) { };
+
        delete_irq_desc(irq);
 }