Re: [patch 02/14] genirq/proc: Avoid formatting zero counts in /proc/interrupts

From: Dmitry Ilvokhin

Date: Mon Mar 09 2026 - 12:00:42 EST


On Wed, Mar 04, 2026 at 07:55:36PM +0100, Thomas Gleixner wrote:
> A large portion of interrupt count entries are zero. There is no point in
> formatting the zero value as it is way cheeper to just emit a constant
> string.
>
> Collect the number of consecutive zero counts and emit them in one go
> before a non-zero count and at the end of the line.
>
> Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxx>
> ---
> include/linux/interrupt.h | 1 +
> kernel/irq/proc.c | 42 +++++++++++++++++++++++++++++++++++++-----
> 2 files changed, 38 insertions(+), 5 deletions(-)
>
> --- a/include/linux/interrupt.h
> +++ b/include/linux/interrupt.h
> @@ -864,6 +864,7 @@ static inline void init_irq_proc(void)
> struct seq_file;
> int show_interrupts(struct seq_file *p, void *v);
> int arch_show_interrupts(struct seq_file *p, int prec);
> +void irq_proc_emit_counts(struct seq_file *p, unsigned int __percpu *cnts);
>
> extern int early_irq_init(void);
> extern int arch_probe_nr_irqs(void);
> --- a/kernel/irq/proc.c
> +++ b/kernel/irq/proc.c
> @@ -450,6 +450,42 @@ int __weak arch_show_interrupts(struct s
> # define ACTUAL_NR_IRQS irq_get_nr_irqs()
> #endif
>
> +#define ZSTR1 " 0"
> +#define ZSTR1_LEN 11

Nit: ZSTR1_LEN could be derived from ZSTR1 to avoid a silent mismatch
if the string is ever changed (which is unlikely, but still).

#define ZSTR1_LEN (sizeof(ZSTR1) - 1)

Reviewed-by: Dmitry Ilvokhin <d@xxxxxxxxxxxx>