From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.mindbit.ro (xs1.mindbit.ro [80.86.107.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 096853090C2 for ; Sat, 21 Mar 2026 16:38:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.86.107.70 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774111136; cv=none; b=nij6kA5hEMryrrLvyizaBz3ocTn6Bh/6Mermo7MKsZAkubBc9pjJToMmQAnn7ajCnv5ukftJJvA68b7YI+aE4CwBZtrhsOJbSa/BAZD8bIEL6Z0x9d0Lw+FU24JgrNi4I+4OLth5OZ5kE7PPw72X074CeyIbmH7gRzAfyd+pAKo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774111136; c=relaxed/simple; bh=nfQ4NkU1GvtBzXWF7TT/V+NBJS7vdPd4G6QHrNbcb54=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=FNONrvGre2TpkDRhA5TNzgL+3nNfKPYSEjV+UUVIWqH6qOeKPZ9TWLVzwCEMmEKTXnimNQ2/LIt3a1PEXENRoebe6MWwfGMRknJZyi1j9M3Td8asJ1zW9z1OFY0ef9dof1+gdxG+fAhtFlEcxGHNKhAIF59JhqoK5nsxKQDFFyE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=rendec.net; spf=pass smtp.mailfrom=rendec.net; dkim=pass (2048-bit key) header.d=rendec.net header.i=@rendec.net header.b=GNilzrIn; arc=none smtp.client-ip=80.86.107.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=rendec.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rendec.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rendec.net header.i=@rendec.net header.b="GNilzrIn" Received: from dog.kanata.rendec.net (pool-174-112-193-187.cpe.net.cable.rogers.com [174.112.193.187]) by mail.mindbit.ro (Postfix) with ESMTPSA id 0CEDCC2420; Sat, 21 Mar 2026 18:38:51 +0200 (EET) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.mindbit.ro 0CEDCC2420 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rendec.net; s=default; t=1774111132; bh=2+8d0DLcS1zwn23CZuTWS+DuujLj8ShidsHCjGxJW+s=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=GNilzrInRKaba3MAkykb8zpaVqK6wfq0ecXaXSUN2A+5/ffOXGMAbiwxMwocSm76G 6lBB789rFh/yLiDtF0ALLw0yJEVuwiUukjh/f39sjv+xZWsNIBdN0P3kkZTsYKx8Lb VKmP5zUKYR0ZTF7bBZYw82UwcJYm3ZrUwpRBpwGffIo+3F+s53SuB4csGAeG3C48u8 7vDLc+LbiH3C5PqST2sZAduQbuACSUkUIN6tCu79K+TNjQzR47gdRItr3JnN9o0YXv ub2SvDA+BulY+q7wH2Aueg8iasNt8eKFI7apfhdD1fYtq33qD/mktceszPIq+Vslhe jKuZAPGgT8Dsg== Message-ID: <881eaff0d6ad4ad6e6b0751f630840c3dafa69b2.camel@rendec.net> Subject: Re: [patch v2 02/14] genirq/proc: Avoid formatting zero counts in /proc/interrupts From: Radu Rendec To: Thomas Gleixner , LKML Cc: x86@kernel.org, Dmitry Ilvokhin , Neil Horman Date: Sat, 21 Mar 2026 12:38:50 -0400 In-Reply-To: <20260320132102.162404736@kernel.org> References: <20260320131108.344376329@kernel.org> <20260320132102.162404736@kernel.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2 (3.56.2-2.fc42) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Fri, 2026-03-20 at 14:21 +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. >=20 > 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. >=20 > Signed-off-by: Thomas Gleixner > Reviewed-by: Dmitry Ilvokhin > --- > V2: Use sizeof() for ZSTR1_LEN - Dmitry > --- > =C2=A0include/linux/interrupt.h |=C2=A0=C2=A0=C2=A0 1 + > =C2=A0kernel/irq/proc.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |= =C2=A0=C2=A0 42 +++++++++++++++++++++++++++++++++++++----- > =C2=A02 files changed, 38 insertions(+), 5 deletions(-) >=20 > --- a/include/linux/interrupt.h > +++ b/include/linux/interrupt.h > @@ -864,6 +864,7 @@ static inline void init_irq_proc(void) > =C2=A0struct seq_file; > =C2=A0int show_interrupts(struct seq_file *p, void *v); > =C2=A0int arch_show_interrupts(struct seq_file *p, int prec); > +void irq_proc_emit_counts(struct seq_file *p, unsigned int __percpu *cnt= s); > =C2=A0 > =C2=A0extern int early_irq_init(void); > =C2=A0extern 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 > =C2=A0# define ACTUAL_NR_IRQS irq_get_nr_irqs() > =C2=A0#endif > =C2=A0 > +#define ZSTR1 "=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 0" > +#define ZSTR1_LEN (sizeof(ZSTR1) - 1) > +#define ZSTR16 ZSTR1 ZSTR1 ZSTR1 ZSTR1 ZSTR1 ZSTR1 ZSTR1 ZSTR1 \ > + ZSTR1 ZSTR1 ZSTR1 ZSTR1 ZSTR1 ZSTR1 ZSTR1 ZSTR1 > +#define ZSTR256 ZSTR16 ZSTR16 ZSTR16 ZSTR16 ZSTR16 ZSTR16 ZSTR16 ZSTR16= \ > + ZSTR16 ZSTR16 ZSTR16 ZSTR16 ZSTR16 ZSTR16 ZSTR16 ZSTR16 > + > +static inline void irq_proc_emit_zero_counts(struct seq_file *p, unsigne= d int zeros) > +{ > + if (!zeros) > + return; > + > + for (unsigned int n =3D min(zeros, 256); n; zeros -=3D n, n =3D min(zer= os, 256)) > + seq_write(p, ZSTR256, n * ZSTR1_LEN); > +} > + > +static inline unsigned int irq_proc_emit_count(struct seq_file *p, unsig= ned int cnt, > + =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 unsigned int zeros) > +{ > + if (!cnt) > + return zeros + 1; > + > + irq_proc_emit_zero_counts(p, zeros); > + seq_put_decimal_ull_width(p, " ", cnt, 10); > + return 0; > +} > + > +void irq_proc_emit_counts(struct seq_file *p, unsigned int __percpu *cnt= s) > +{ > + unsigned int cpu, zeros =3D 0; > + > + for_each_online_cpu(cpu) > + zeros =3D irq_proc_emit_count(p, per_cpu(*cnts, cpu), zeros); > + irq_proc_emit_zero_counts(p, zeros); > +} > + > =C2=A0int show_interrupts(struct seq_file *p, void *v) > =C2=A0{ > =C2=A0 const unsigned int nr_irqs =3D irq_get_nr_irqs(); > @@ -485,11 +521,7 @@ int show_interrupts(struct seq_file *p, > =C2=A0 return 0; > =C2=A0 > =C2=A0 seq_printf(p, "%*d:", prec, i); > - for_each_online_cpu(j) { > - unsigned int cnt =3D desc->kstat_irqs ? per_cpu(desc->kstat_irqs->cnt,= j) : 0; > - > - seq_put_decimal_ull_width(p, " ", cnt, 10); > - } > + irq_proc_emit_counts(p, &desc->kstat_irqs->cnt); > =C2=A0 seq_putc(p, ' '); > =C2=A0 > =C2=A0 guard(raw_spinlock_irq)(&desc->lock); Reviewed-by: Radu Rendec