From nobody Mon Jun 8 20:53:43 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 356692D8771; Tue, 26 May 2026 14:22:23 +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=1779805345; cv=none; b=p1bnRjAf5Btx1W3kMNHUez3k97LnNzDOu7CEYffnjd5uhGOE15P16I85BStlDsMLF8ZjyOYIPw2/vFhgPKVoLfBpW1Y4/eR2jJ8VgWm8vnJv208gz9e7EMp8oNMeAJKR5anKnZvaYa+1blwFi9nKl0a6WoWWJCfvDWq8LCmG25c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779805345; c=relaxed/simple; bh=15OT0Fd5cgkTaZ9rCdHYKnKz1B7B4Kka1cobaFNJEvs=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=UsUueYdypCvvd4GfsTJRW3G+514mcQP+/ZqHctt0xrWVcqfAQ9sPxM4npZCRd9+uS99c67IGO2VMBkEWwHHHGbM1kD6q+7FM0eWpYnJZNRZnA0GR+oc4ZEY3XudMonvkk3CoiVBc5sFvI9xiy4iOzYN5qtIHyzgh1+T41aljiLg= 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=TUZ9uKdS; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=A8NkGegc; 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="TUZ9uKdS"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="A8NkGegc" Date: Tue, 26 May 2026 14:22:19 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1779805341; 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=NN4qP3m+PB5mLmYjz1brwBxojUVMpHdwTkyZWSVLA9g=; b=TUZ9uKdSqYAMedPRTNroZSy9o/uVquKLQy1zK0znt9A4k6yQJef5wCPIHwyaPLY6FNPI9o gcyTMMbvCBSeOigI+tMmCQlW94q8T7q5rPrIKfWuCufiaYbtz6kAWyCjcq9Xx559opS2we c3LUY1BBDRJAxMoGC+4iADlcNh5Ab1IAjBMUOQtRZM/HY4C7yqSI1PZcOAxwqGU9SfEVAa 4xezyuMTWPb7dTzPKIZfUpFFnD8y9YVNRF+nI7avpKpsrDCwIo/x+m1Wf52yEZMuYq1+ok AJDjgN3VdXGETAAVWcldfEHX4F6sA8UBTw3b8YWV+dp4kNQj/1n5DxqSjLXl1A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1779805341; 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=NN4qP3m+PB5mLmYjz1brwBxojUVMpHdwTkyZWSVLA9g=; b=A8NkGegcmAUeLFDXcigUqcE6KmaPlhnw9+S+m0c5j/lBeflqra4udXZqBepDPQzj0uhLjr yc1iywHT7cPb6iCQ== 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/proc: Runtime size the chip name Cc: Thomas Gleixner , Michael Kelley , Dmitry Ilvokhin , x86@kernel.org, linux-kernel@vger.kernel.org, maz@kernel.org In-Reply-To: <20260517194932.085786035@kernel.org> References: <20260517194932.085786035@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177980533947.1039918.15601589948971273150.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: 61b51a167c524b65a59b1342e70c2008d514a796 Gitweb: https://git.kernel.org/tip/61b51a167c524b65a59b1342e70c2008d= 514a796 Author: Thomas Gleixner AuthorDate: Sun, 17 May 2026 22:02:44 +02:00 Committer: Thomas Gleixner CommitterDate: Tue, 26 May 2026 16:21:15 +02:00 genirq/proc: Runtime size the chip name The chip name column in the /proc/interrupt output is 8 characters and right aligned, which causes visual clutter due to the fixed length and the alignment. Many interrupt chips, e.g. PCI/MSI[X] have way longer names. Update the length when a chip is assigned to an interrupt and utilize this information for the output. Align it left so all chip names start at the begin of the column. Update the GDB script as well and disentangle the header maze so it actually works with all .config combinations. Signed-off-by: Thomas Gleixner Tested-by: Michael Kelley Reviewed-by: Dmitry Ilvokhin Link: https://patch.msgid.link/20260517194932.085786035@kernel.org --- kernel/irq/chip.c | 6 ++-- kernel/irq/debugfs.h | 44 +++++++++++++++++++++++++++++- kernel/irq/internals.h | 48 ++------------------------------ kernel/irq/irqdomain.c | 5 ++- kernel/irq/proc.c | 33 ++++++++++++++++++---- kernel/irq/proc.h | 13 +++++++++- scripts/gdb/linux/interrupts.py | 23 +++++++++------ 7 files changed, 111 insertions(+), 61 deletions(-) create mode 100644 kernel/irq/debugfs.h create mode 100644 kernel/irq/proc.h diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index 2d283d1..9347779 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -47,9 +47,11 @@ int irq_set_chip(unsigned int irq, const struct irq_chip= *chip) scoped_irqdesc->irq_data.chip =3D (struct irq_chip *)(chip ?: &no_irq_ch= ip); ret =3D 0; } - /* For !CONFIG_SPARSE_IRQ make the irq show up in allocated_irqs. */ - if (!ret) + if (!ret) { + /* For !CONFIG_SPARSE_IRQ make the irq show up in allocated_irqs. */ irq_mark_irq(irq); + irq_proc_update_chip(chip); + } return ret; } EXPORT_SYMBOL(irq_set_chip); diff --git a/kernel/irq/debugfs.h b/kernel/irq/debugfs.h new file mode 100644 index 0000000..8a9360d --- /dev/null +++ b/kernel/irq/debugfs.h @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _KERNEL_IRQ_DEBUGFS_H +#define _KERNEL_IRQ_DEBUGFS_H + +#ifdef CONFIG_GENERIC_IRQ_DEBUGFS +#include + +struct irq_bit_descr { + unsigned int mask; + char *name; +}; + +#define BIT_MASK_DESCR(m) { .mask =3D m, .name =3D #m } + +void irq_debug_show_bits(struct seq_file *m, int ind, unsigned int state, + const struct irq_bit_descr *sd, int size); + +void irq_add_debugfs_entry(unsigned int irq, struct irq_desc *desc); +static inline void irq_remove_debugfs_entry(struct irq_desc *desc) +{ + debugfs_remove(desc->debugfs_file); + kfree(desc->dev_name); +} +void irq_debugfs_copy_devname(int irq, struct device *dev); +# ifdef CONFIG_IRQ_DOMAIN +void irq_domain_debugfs_init(struct dentry *root); +# else +static inline void irq_domain_debugfs_init(struct dentry *root) +{ +} +# endif +#else /* CONFIG_GENERIC_IRQ_DEBUGFS */ +static inline void irq_add_debugfs_entry(unsigned int irq, struct irq_desc= *d) +{ +} +static inline void irq_remove_debugfs_entry(struct irq_desc *d) +{ +} +static inline void irq_debugfs_copy_devname(int irq, struct device *dev) +{ +} +#endif /* CONFIG_GENERIC_IRQ_DEBUGFS */ + +#endif diff --git a/kernel/irq/internals.h b/kernel/irq/internals.h index 37eec03..f9c099d 100644 --- a/kernel/irq/internals.h +++ b/kernel/irq/internals.h @@ -12,6 +12,9 @@ #include #include =20 +#include "debugfs.h" +#include "proc.h" + #ifdef CONFIG_SPARSE_IRQ # define MAX_SPARSE_IRQS INT_MAX #else @@ -149,12 +152,6 @@ 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 - struct irq_desc *irq_find_desc_at_or_after(unsigned int offset); =20 extern bool irq_can_set_affinity_usr(unsigned int irq); @@ -398,42 +395,3 @@ static inline struct irq_data *irqd_get_parent_data(st= ruct irq_data *irqd) return NULL; #endif } - -#ifdef CONFIG_GENERIC_IRQ_DEBUGFS -#include - -struct irq_bit_descr { - unsigned int mask; - char *name; -}; - -#define BIT_MASK_DESCR(m) { .mask =3D m, .name =3D #m } - -void irq_debug_show_bits(struct seq_file *m, int ind, unsigned int state, - const struct irq_bit_descr *sd, int size); - -void irq_add_debugfs_entry(unsigned int irq, struct irq_desc *desc); -static inline void irq_remove_debugfs_entry(struct irq_desc *desc) -{ - debugfs_remove(desc->debugfs_file); - kfree(desc->dev_name); -} -void irq_debugfs_copy_devname(int irq, struct device *dev); -# ifdef CONFIG_IRQ_DOMAIN -void irq_domain_debugfs_init(struct dentry *root); -# else -static inline void irq_domain_debugfs_init(struct dentry *root) -{ -} -# endif -#else /* CONFIG_GENERIC_IRQ_DEBUGFS */ -static inline void irq_add_debugfs_entry(unsigned int irq, struct irq_desc= *d) -{ -} -static inline void irq_remove_debugfs_entry(struct irq_desc *d) -{ -} -static inline void irq_debugfs_copy_devname(int irq, struct device *dev) -{ -} -#endif /* CONFIG_GENERIC_IRQ_DEBUGFS */ diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index cc93abf..f15c9f1 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -20,6 +20,8 @@ #include #include =20 +#include "proc.h" + static LIST_HEAD(irq_domain_list); static DEFINE_MUTEX(irq_domain_mutex); =20 @@ -1532,6 +1534,7 @@ int irq_domain_set_hwirq_and_chip(struct irq_domain *= domain, unsigned int virq, irq_data->chip =3D (struct irq_chip *)(chip ? chip : &no_irq_chip); irq_data->chip_data =3D chip_data; =20 + irq_proc_update_chip(chip); return 0; } EXPORT_SYMBOL_GPL(irq_domain_set_hwirq_and_chip); @@ -2081,7 +2084,7 @@ static void irq_domain_free_one_irq(struct irq_domain= *domain, unsigned int virq #endif /* CONFIG_IRQ_DOMAIN_HIERARCHY */ =20 #ifdef CONFIG_GENERIC_IRQ_DEBUGFS -#include "internals.h" +#include "debugfs.h" =20 static struct dentry *domain_dir; =20 diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c index 1cb47a8..9a96800 100644 --- a/kernel/irq/proc.c +++ b/kernel/irq/proc.c @@ -457,10 +457,14 @@ int __weak arch_show_interrupts(struct seq_file *p, i= nt prec) return 0; } =20 +static DEFINE_RAW_SPINLOCK(irq_proc_constraints_lock); + static struct irq_proc_constraints { unsigned int num_prec; + unsigned int chip_width; } irq_proc_constraints __read_mostly =3D { .num_prec =3D 4, + .chip_width =3D 8, }; =20 #ifndef ACTUAL_NR_IRQS @@ -473,7 +477,23 @@ void irq_proc_calc_prec(void) =20 for (prec =3D 4, n =3D 10000; prec < 10 && n <=3D total_nr_irqs; ++prec) n *=3D 10; - WRITE_ONCE(irq_proc_constraints.num_prec, prec); + + guard(raw_spinlock_irqsave)(&irq_proc_constraints_lock); + if (prec > irq_proc_constraints.num_prec) + WRITE_ONCE(irq_proc_constraints.num_prec, prec); +} + +void irq_proc_update_chip(const struct irq_chip *chip) +{ + unsigned int len =3D chip && chip->name ? strlen(chip->name) : 0; + + if (!len || len <=3D READ_ONCE(irq_proc_constraints.chip_width)) + return; + + /* Can be invoked from interrupt disabled contexts */ + guard(raw_spinlock_irqsave)(&irq_proc_constraints_lock); + if (len > irq_proc_constraints.chip_width) + WRITE_ONCE(irq_proc_constraints.chip_width, len); } =20 /* Same as seq_put_decimal_ull_width(p, " ", cnt, 10) */ @@ -515,6 +535,7 @@ void irq_proc_emit_counts(struct seq_file *p, unsigned = int __percpu *cnts) =20 int show_interrupts(struct seq_file *p, void *v) { + unsigned int chip_width =3D READ_ONCE(irq_proc_constraints.chip_width); unsigned int prec =3D READ_ONCE(irq_proc_constraints.num_prec); int i =3D *(loff_t *) v, j; struct irqaction *action; @@ -550,18 +571,20 @@ int show_interrupts(struct seq_file *p, void *v) irq_proc_emit_counts(p, &desc->kstat_irqs->cnt); else irq_proc_emit_zero_counts(p, num_online_cpus()); - seq_putc(p, ' '); + + /* Enforce a visual gap */ + seq_write(p, " ", 2); =20 guard(raw_spinlock_irq)(&desc->lock); if (desc->irq_data.chip) { if (desc->irq_data.chip->irq_print_chip) desc->irq_data.chip->irq_print_chip(&desc->irq_data, p); else if (desc->irq_data.chip->name) - seq_printf(p, "%8s", desc->irq_data.chip->name); + seq_printf(p, "%-*s", chip_width, desc->irq_data.chip->name); else - seq_printf(p, "%8s", "-"); + seq_printf(p, "%-*s", chip_width, "-"); } else { - seq_printf(p, "%8s", "None"); + seq_printf(p, "%-*s", chip_width, "None"); } =20 seq_putc(p, ' '); diff --git a/kernel/irq/proc.h b/kernel/irq/proc.h new file mode 100644 index 0000000..0631d57 --- /dev/null +++ b/kernel/irq/proc.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _KERNEL_IRQ_PROC_H +#define _KERNEL_IRQ_PROC_H + +#if defined(CONFIG_PROC_FS) && defined(CONFIG_GENERIC_IRQ_SHOW) +void irq_proc_calc_prec(void); +void irq_proc_update_chip(const struct irq_chip *chip); +#else +static inline void irq_proc_calc_prec(void) { } +static inline void irq_proc_update_chip(const struct irq_chip *chip) { } +#endif + +#endif diff --git a/scripts/gdb/linux/interrupts.py b/scripts/gdb/linux/interrupts= .py index e967343..a68ae91 100644 --- a/scripts/gdb/linux/interrupts.py +++ b/scripts/gdb/linux/interrupts.py @@ -20,7 +20,7 @@ def irq_desc_is_chained(desc): def irqd_is_level(desc): return desc['irq_data']['common']['state_use_accessors'] & constants.L= X_IRQD_LEVEL =20 -def show_irq_desc(prec, irq): +def show_irq_desc(prec, chip_width, irq): text =3D "" =20 desc =3D mapletree.mtree_load(gdb.parse_and_eval("&sparse_irqs"), irq) @@ -58,7 +58,7 @@ def show_irq_desc(prec, irq): else: name =3D "-" =20 - text +=3D " %-8s" % (name) + text +=3D " %-*s" % (chip_width, name) =20 if desc['irq_data']['domain']: text +=3D " %*lu" % (prec, desc['irq_data']['hwirq']) @@ -171,11 +171,18 @@ class LxInterruptList(gdb.Command): =20 def invoke(self, arg, from_tty): nr_irqs =3D gdb.parse_and_eval("total_nr_irqs") - prec =3D 4 - j =3D 10000 - while prec < 10 and j <=3D nr_irqs: - prec +=3D 1 - j *=3D 10 + constr =3D utils.gdb_eval_or_none('irq_proc_constraints') + + if constr: + prec =3D int(constr['num_prec']) + chip_width =3D int(constr['chip_width']) + else: + prec =3D 4 + j =3D 10000 + while prec < 10 and j <=3D nr_irqs: + prec +=3D 1 + j *=3D 10 + chip_width =3D 8 =20 gdb.write("%*s" % (prec + 8, "")) for cpu in cpus.each_online_cpu(): @@ -186,7 +193,7 @@ class LxInterruptList(gdb.Command): raise gdb.GdbError("Unable to find the sparse IRQ tree, is CON= FIG_SPARSE_IRQ enabled?") =20 for irq in range(nr_irqs): - gdb.write(show_irq_desc(prec, irq)) + gdb.write(show_irq_desc(prec, chip_width, irq)) gdb.write(arch_show_interrupts(prec)) =20 =20