From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 1083D3D9DCB for ; Tue, 19 May 2026 21:24:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779225868; cv=none; b=EiTnw8hPso63yABDyESS/Vlw1dVu0zYqsld6KZicQu/bpUH8wCKont8PmY/udMBP64eB4EjoCt7jHL7ZkftoX9jZobPoA2dgtKX7EuY1iCEj1vbE2ogr3n5KjgafJ2MTN8QxvrA9jbTYOreA1YsgZX9vrC+NYjRnNUL6CtSN7Hk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779225868; c=relaxed/simple; bh=+x8jTWg54C7gG9PfUGImRi6RsAsN3A6gt2hkLWTPTws=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=K8qqHN5RW0n7mnSCPw4AkPkVh4WYHa9pAJsijuyeCgBn0zDtSNjCOJxeOdR61KgNOWN2EshWqP21UnaLRd55cqDa0zG10b1EX+KsXXmvyuwibgEQBi3h1tSK/jadnOXYR6ief0DRsIwghycyUYuzgduedatf9NQmJZZd/yJBHTY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=CyIy9+iF; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="CyIy9+iF" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64JG9GMP883231; Tue, 19 May 2026 21:24:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=Q3uJpx uk3mZ+thWAfwTdaYI/LJh2v+iniuWwz0OyQTI=; b=CyIy9+iFkpghguMzU8yTZt BnoDFyVS0i95sJWLW6oc+yj3wT1EQt2EIlmOZuZGfVF9GZPGwDRtdFYcjCIH0IAM Lw+gVPl5jSwsi7FjCVlzAuGaEaVTvWRaXx2IoXkocHLzkva5NILNHlK3T/k7TWB5 kMgqUb7bp187j/SGr40daH2TSdp6a2P2CKtmR+YqIfLlxPg5KXTwR+P5mhNDRGRB VtdrdQ6w/P295hINBp8i1F3Ax9cX2SRjvs6q9htbTLfYDeZpMsMu/w1YLUq7VZ5v /CS6/NnRKPM+qHYO6MSAuxP4tGa75Vk7X74Tn7rx1NJy8n7IayUf9FT6jPfhkQ1Q == Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4e6h8mq5xd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 19 May 2026 21:24:16 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64JLOGGF024740; Tue, 19 May 2026 21:24:16 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4e754gcbud-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 19 May 2026 21:24:15 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64JLOE8H57278858 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 19 May 2026 21:24:14 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4C94420043; Tue, 19 May 2026 21:24:14 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E489C20040; Tue, 19 May 2026 21:24:11 +0000 (GMT) Received: from [9.124.216.9] (unknown [9.124.216.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 19 May 2026 21:24:11 +0000 (GMT) Message-ID: <61c222f3-48e1-436a-bb03-8e3753cba3eb@linux.ibm.com> Date: Wed, 20 May 2026 02:54:10 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [patch V6 02/16] genirq/proc: Avoid formatting zero counts in /proc/interrupts To: Thomas Gleixner , LKML Cc: x86@kernel.org, Michael Kelley , Dmitry Ilvokhin , Radu Rendec , Jan Kiszka , Kieran Bingham , Florian Fainelli , Marc Zyngier References: <20260517194421.705253664@kernel.org> <20260517194931.034728540@kernel.org> Content-Language: en-US From: Shrikanth Hegde In-Reply-To: <20260517194931.034728540@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-GUID: bnPj1KA12yuW6ZTzOPQchWYa_8BPo88t X-Authority-Analysis: v=2.4 cv=GYMnWwXL c=1 sm=1 tr=0 ts=6a0cd501 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=IkcTkHD0fZMA:10 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=VwQbUJbxAAAA:8 a=UqCG9HQmAAAA:8 a=QaIFIwmdAAAA:8 a=coPjFYPWAAAA:8 a=VnNF1IyMAAAA:8 a=KlU0QHeLMleYOoVUw1QA:9 a=QEXdDO2ut3YA:10 a=H0j26ktMJjVwFu0eHUYC:22 a=PHqHxvoSLtS9In37M5wo:22 X-Proofpoint-ORIG-GUID: VHeZ4gRHCGFoAp-jIhokNascEBGqa2In X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTE5MDIxMSBTYWx0ZWRfX8FZoMMP2cjh9 mdPoH/uyN3kKzduMIBZr7h6AZpULrrr0nG3SgJhVEub2y6tUAp9or6PYOjVKKkOgXQUQfQbR7KG QgAeaNNJjhMKF8RrgbKzeyEFMZyipaewuIOQiyC1YiELkLFeKv+ABRatkOExg0aCOPCC3Ug4+id so/5bqGK1QtcI+hYIUIhgnjZMrGbonQwOWiH1BGzXYVhwSzJzhSmrP3v3n/AYYGLAqfM8IDMoaQ JYYb0CTwnwQAxuP0K1MK9yLuDoR9gUc8yYCA843+IF4I3A0b1L4+UNRfZn8+hHz2wViq3c/+9jt BOm1YbhJvfqmsOwuU614dUwlRNZOwcYTo8kaCq3aYw/tKkrs/JF0k/LdIqVZj5rPHykRnqcApTU EPNVftaXGJ6ZexjO7YZIlBhP0dL2xpDdsmVMqJTMr0AF0ksAlw4EQ1ZR+/z8OQjQWGimq5xDR/U 7uvikwPO9QAiQfeZunA== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-19_05,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 adultscore=0 suspectscore=0 spamscore=0 clxscore=1015 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605190211 Hi Thomas. On 5/18/26 1:31 AM, Thomas Gleixner wrote: > From: Thomas Gleixner > > 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. nit: s/cheeper/cheaper > > 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 > Tested-by: Michael Kelley > Reviewed-by: Dmitry Ilvokhin > Reviewed-by: Radu Rendec > --- > V2: Use sizeof() for ZSTR1_LEN - Dmitry > --- > include/linux/interrupt.h | 1 + > kernel/irq/proc.c | 43 ++++++++++++++++++++++++++++++++++++++----- > 2 files changed, 39 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,43 @@ int __weak arch_show_interrupts(struct s > # define ACTUAL_NR_IRQS irq_get_nr_irqs() > #endif > > +/* Same as seq_put_decimal_ull_width(p, " ", cnt, 10) */ nit: is this comment still valid to be here? > +#define ZSTR1 " 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, unsigned int zeros) > +{ > + if (!zeros) > + return; > + > + for (unsigned int n = min(zeros, 256); n; zeros -= n, n = min(zeros, 256)) > + seq_write(p, ZSTR256, n * ZSTR1_LEN); > +} > + > +static inline unsigned int irq_proc_emit_count(struct seq_file *p, unsigned int cnt, > + 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 *cnts) > +{ > + unsigned int cpu, zeros = 0; > + > + for_each_online_cpu(cpu) > + zeros = irq_proc_emit_count(p, per_cpu(*cnts, cpu), zeros); > + irq_proc_emit_zero_counts(p, zeros); > +} > + > int show_interrupts(struct seq_file *p, void *v) > { > const unsigned int nr_irqs = irq_get_nr_irqs(); > @@ -485,11 +522,7 @@ int show_interrupts(struct seq_file *p, > return 0; > > seq_printf(p, "%*d:", prec, i); > - for_each_online_cpu(j) { > - unsigned int cnt = 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); > seq_putc(p, ' '); > > guard(raw_spinlock_irq)(&desc->lock); > Other than nits, feel free to include Reviewed-by: Shrikanth Hegde