From nobody Mon Jun 8 20:42:48 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 720CD3FFABF; Tue, 26 May 2026 14:22:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779805350; cv=none; b=NBo0jIhqhO5R70NJS63h3y3H/bXWKtW4jqroCNyhxMCJND43x5GGRrh9UxVka2KYOA7agZz36H7Dwg1NHuj3XNGZaJQIXeVjerHjrgXC4Isu8/oG3FFzXdyBrGFCCUruhWhtfuIR8g2cnJiaRnxGqKp5GK3WsWcvYmqo/cbUkaY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779805350; c=relaxed/simple; bh=odGb0kfjeS3bKcTAsSRSasZZmOLBNY/EXKUVZl2selM=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=UmISkIVPXNIniyydvMUI6m29Qu9QY6fKFbp1dugFIGzFTdjw2VcX8Jo+MDOU2eujKP6TxBM5lm7RKximZ1YUhZEYY961kpGtuA2VBYg/VBLZclY/7H/Ix8W1c4eSi/8WmOjL1vXQnLZW2fLn2p3Zmn0GDJeJy47HhLDkiYUhU1w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Md4/fYE3; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=H11Rr0S7; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Md4/fYE3"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="H11Rr0S7" Date: Tue, 26 May 2026 14:22:25 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1779805346; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=V4V0WLnXjeKNZZq4TVYuRmNWoaf0ejvEa75RnEmjU0A=; b=Md4/fYE3pgxmUOZYM6pAYXI7NeABrpdUhunqPJRomgudihLsgX+1hza0dMFP6qZydVQcdN k5cdGVApFMdOkTaod/XLCTtLwE+rU09P5Gl76nBSquHa9PmYEGDkbelAJr3TMzrpjXMOpa eieFZfk4B7yYUC0XEEH1VEb4M/K/oesIzyoJsyFhUMDN1losfpoqriZ0PnH/De6ZuszYWw yXPoIpWg8KI1HiaSAwisti8/I+X1di8vLvbmt8pR3qYF88aEVnsGbAYnm6cK0fJAtFTEpm QG1VMrPdxXw+qxfqEd11RqcizUHdkArSgSflE+HtOltcSEQeq900NyXm2UbX4Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1779805346; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=V4V0WLnXjeKNZZq4TVYuRmNWoaf0ejvEa75RnEmjU0A=; b=H11Rr0S7JYet6hTseYwaOKdPeXacjbNMTFO6IBP81UoucI8d/PaSGdxt1kYsaWvNRQsH7g cvDo7XH6lekGI0CQ== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: irq/core] genirq: Calculate precision only when required Cc: Thomas Gleixner , Michael Kelley , Dmitry Ilvokhin , Radu Rendec , x86@kernel.org, linux-kernel@vger.kernel.org, maz@kernel.org In-Reply-To: <20260517194931.760664517@kernel.org> References: <20260517194931.760664517@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177980534521.1039918.7152356772020764659.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the irq/core branch of tip: Commit-ID: 2d62735f1d4a2832af367c9e3de04bfb280a945c Gitweb: https://git.kernel.org/tip/2d62735f1d4a2832af367c9e3de04bfb2= 80a945c Author: Thomas Gleixner AuthorDate: Sun, 17 May 2026 22:02:24 +02:00 Committer: Thomas Gleixner CommitterDate: Tue, 26 May 2026 16:21:14 +02:00 genirq: Calculate precision only when required Calculating the precision of the interrupt number column on every initial show_interrupt() invocation is a pointless exercise as the underlying maximum number of interrupts rarely changes. Calculate it only when that number is modified and let show_interrupts() use the cached value. Signed-off-by: Thomas Gleixner Tested-by: Michael Kelley Reviewed-by: Dmitry Ilvokhin Reviewed-by: Radu Rendec Link: https://patch.msgid.link/20260517194931.760664517@kernel.org --- kernel/irq/internals.h | 6 ++++++ kernel/irq/irqdesc.c | 10 ++++++---- kernel/irq/proc.c | 33 +++++++++++++++++++++++---------- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/kernel/irq/internals.h b/kernel/irq/internals.h index e5f3d31..be702dd 100644 --- a/kernel/irq/internals.h +++ b/kernel/irq/internals.h @@ -134,6 +134,12 @@ static inline void unregister_handler_proc(unsigned in= t irq, static inline void irq_proc_update_valid(struct irq_desc *desc) { } #endif =20 +#if defined(CONFIG_PROC_FS) && defined(CONFIG_GENERIC_IRQ_SHOW) +void irq_proc_calc_prec(void); +#else +static inline void irq_proc_calc_prec(void) { } +#endif + extern bool irq_can_set_affinity_usr(unsigned int irq); =20 extern int irq_do_set_affinity(struct irq_data *data, diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c index a7ce1e8..90595ee 100644 --- a/kernel/irq/irqdesc.c +++ b/kernel/irq/irqdesc.c @@ -157,13 +157,12 @@ EXPORT_SYMBOL_GPL(irq_get_nr_irqs); * * Return: @nr. */ -unsigned int irq_set_nr_irqs(unsigned int nr) +unsigned int __init irq_set_nr_irqs(unsigned int nr) { total_nr_irqs =3D nr; - + irq_proc_calc_prec(); return nr; } -EXPORT_SYMBOL_GPL(irq_set_nr_irqs); =20 static DEFINE_MUTEX(sparse_irq_lock); static struct maple_tree sparse_irqs =3D MTREE_INIT_EXT(sparse_irqs, @@ -544,6 +543,7 @@ static bool irq_expand_nr_irqs(unsigned int nr) if (nr > MAX_SPARSE_IRQS) return false; total_nr_irqs =3D nr; + irq_proc_calc_prec(); return true; } =20 @@ -572,6 +572,7 @@ int __init early_irq_init(void) desc =3D alloc_desc(i, node, 0, NULL, NULL); irq_insert_desc(i, desc); } + irq_proc_calc_prec(); return arch_early_irq_init(); } =20 @@ -592,7 +593,7 @@ int __init early_irq_init(void) =20 init_irq_default_affinity(); =20 - printk(KERN_INFO "NR_IRQS: %d\n", NR_IRQS); + pr_info("NR_IRQS: %d\n", NR_IRQS); =20 count =3D ARRAY_SIZE(irq_desc); =20 @@ -602,6 +603,7 @@ int __init early_irq_init(void) goto __free_desc_res; } =20 + irq_proc_calc_prec(); return arch_early_irq_init(); =20 __free_desc_res: diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c index cc9c7c9..c635fb6 100644 --- a/kernel/irq/proc.c +++ b/kernel/irq/proc.c @@ -457,10 +457,25 @@ int __weak arch_show_interrupts(struct seq_file *p, i= nt prec) return 0; } =20 +static struct irq_proc_constraints { + unsigned int num_prec; +} irq_proc_constraints __read_mostly =3D { + .num_prec =3D 3, +}; + #ifndef ACTUAL_NR_IRQS # define ACTUAL_NR_IRQS total_nr_irqs #endif =20 +void irq_proc_calc_prec(void) +{ + unsigned int prec, n; + + for (prec =3D 3, n =3D 1000; prec < 10 && n <=3D total_nr_irqs; ++prec) + n *=3D 10; + WRITE_ONCE(irq_proc_constraints.num_prec, prec); +} + /* Same as seq_put_decimal_ull_width(p, " ", cnt, 10) */ #define ZSTR1 " 0" #define ZSTR1_LEN (sizeof(ZSTR1) - 1) @@ -500,9 +515,7 @@ void irq_proc_emit_counts(struct seq_file *p, unsigned = int __percpu *cnts) =20 int show_interrupts(struct seq_file *p, void *v) { - const unsigned int nr_irqs =3D total_nr_irqs; - static int prec; - + unsigned int prec =3D READ_ONCE(irq_proc_constraints.num_prec); int i =3D *(loff_t *) v, j; struct irqaction *action; struct irq_desc *desc; @@ -515,9 +528,6 @@ int show_interrupts(struct seq_file *p, void *v) =20 /* print header and calculate the width of the first column */ if (i =3D=3D 0) { - for (prec =3D 3, j =3D 1000; prec < 10 && j <=3D nr_irqs; ++prec) - j *=3D 10; - seq_printf(p, "%*s", prec + 8, ""); for_each_online_cpu(j) seq_printf(p, "CPU%-8d", j); @@ -553,13 +563,16 @@ int show_interrupts(struct seq_file *p, void *v) } else { seq_printf(p, "%8s", "None"); } + + seq_putc(p, ' '); if (desc->irq_data.domain) - seq_printf(p, " %*lu", prec, desc->irq_data.hwirq); + seq_put_decimal_ull_width(p, "", desc->irq_data.hwirq, prec); else seq_printf(p, " %*s", prec, ""); -#ifdef CONFIG_GENERIC_IRQ_SHOW_LEVEL - seq_printf(p, " %-8s", irqd_is_level_type(&desc->irq_data) ? "Level" : "E= dge"); -#endif + + if (IS_ENABLED(CONFIG_GENERIC_IRQ_SHOW_LEVEL)) + seq_printf(p, " %-8s", irqd_is_level_type(&desc->irq_data) ? "Level" : "= Edge"); + if (desc->name) seq_printf(p, "-%-8s", desc->name); =20