Re: [patch V4 15/15] genirq/proc: Speed up /proc/interrupts iteration
From: Dmitry Ilvokhin
Date: Tue Mar 31 2026 - 12:18:13 EST
On Tue, Mar 31, 2026 at 09:26:40AM +0200, Thomas Gleixner wrote:
> From: Thomas Gleixner <tglx@xxxxxxxxxx>
>
> Reading /proc/interrupts iterates over the interrupt number space one by
> one and looks up the descriptors one by one. That's just a waste of time.
>
> When CONFIG_GENERIC_IRQ_SHOW is enabled this can utilize the maple tree and
> cache the descriptor pointer efficiently for the sequence file operations.
>
> Implement a CONFIG_GENERIC_IRQ_SHOW specific version in the core code and
> leave the fs/proc/ variant for the legacy architectures which ignore generic
> code.
>
> This reduces the time wasted for looking up the next record significantly.
>
> Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxx>
> ---
[...]
>
> - /* print header and calculate the width of the first column */
> - if (i == 0) {
> - seq_printf(p, "%*s", prec + 8, "");
> - for_each_online_cpu(j)
> - seq_printf(p, "CPU%-8d", j);
> + /* print header for the first interrupt indicated by !p>private */
nit: This comment seems a bit out of place here, since we are looking at
constr->print_header directly here.
> + if (constr->print_header) {
> + unsigned int cpu;
> +
> + seq_printf(p, "%*s", constr->num_prec + 8, "");
> + for_each_online_cpu(cpu)
> + seq_printf(p, "CPU%-8d", cpu);
> seq_putc(p, '\n');
> + constr->print_header = false;
> }
While at it, moving the print_header block above the ARCH_PROC_IRQDESC
check would make the code more robust. If there are no valid descriptors
to display, the CPU column header would still be printed before
arch_show_interrupts() output. Not a practical issue, but it makes the
logic obviously correct.
Reviewed-by: Dmitry Ilvokhin <d@xxxxxxxxxxxx>