From nobody Mon Jun 8 20:45:39 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 ED5A24014AA; Tue, 26 May 2026 14:22:32 +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=1779805354; cv=none; b=PBH83r0zpPJ176nBSnNr1MgxJ08qjLqYrGfmE+Yaee8mS412aTwvOkWdAgQSlc0afe/7dQaCHV7onfwkVE8d8XImUA8mn3dh/eYf0XpYP+I09OjIJKjPL0msAY9fyXxpbg9dLSH/mDfdWYEHxPD564APIWUzs+v2AMdxArmzyIs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779805354; c=relaxed/simple; bh=15Zbo5wOWxS4xzFTQ9wyUplb625w/ylwVjfYDHsbP5Y=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=SCLRzms4fOmgLbUNmyhzJb2xv3BPUqJohoaSTU7zyM18jEhVa9w21dz5tI6Jah/pjWescNQIVnmXAXZHrOitOfLQ+tgH36zBj9rAzrzH+novr573gnVSpC+qbU/U4wMwI3+zW62LZFH0pWKMJsppdPZXuPvbGmv5c9wCkbrDcNM= 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=kJmt4LDn; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=aeq07R2q; 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="kJmt4LDn"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="aeq07R2q" Date: Tue, 26 May 2026 14:22:26 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1779805348; 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=NiuUKnI7k89bppPMLXXOdsEp7ASiPvbyuxJ+6TXCv/k=; b=kJmt4LDngsJQVP2DS3ZgGtyOo+N5/utSlNmeF45PGT8dIuontrUCWiNPP8kydKmyieo1gF rJxSF7VKTwE25j54u9ypnBsWN/fchCqEpQAAkWV4M2on+29VO8HQ3FnRZRxoZq5P7imiJ7 4LgKH2aNSHrd3QvQxJt96qsf/xBCyNAw7hVPytIOX5pHyoYVpV8aG81x2OzPQitHQNXb1e FZdI6500otxVQhvAvwyroSBPe/PpPG1VToxABr5lEtGlCrOjqOax5Pm1aJbr/RsVUn1oer +u0FUKNGkH7ciSwDOk+0r1utWdkvS3VaAUrni0VQf/4LU2OGEIfuOFORaXKCuQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1779805348; 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=NiuUKnI7k89bppPMLXXOdsEp7ASiPvbyuxJ+6TXCv/k=; b=aeq07R2qFvP/i9pSC2+h95qqSTj2FDM0M3BTssxtH/fPrUD1U6slIxPfKw0l3OzGxRCvJj U79HIJOGG77HC3BA== 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: Cache the condition for /proc/interrupts exposure Cc: Thomas Gleixner , Michael Kelley , Dmitry Ilvokhin , Radu Rendec , x86@kernel.org, linux-kernel@vger.kernel.org, maz@kernel.org In-Reply-To: <20260517194931.680943749@kernel.org> References: <20260517194931.680943749@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177980534667.1039918.9288772577319187654.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: 4892e5e71ec9c942293cea7fd26e0c76179211ed Gitweb: https://git.kernel.org/tip/4892e5e71ec9c942293cea7fd26e0c761= 79211ed Author: Thomas Gleixner AuthorDate: Sun, 17 May 2026 22:02:19 +02:00 Committer: Thomas Gleixner CommitterDate: Tue, 26 May 2026 16:21:13 +02:00 genirq: Cache the condition for /proc/interrupts exposure show_interrupts() evaluates a boatload of conditions to establish whether it should expose an interrupt in /proc/interrupts or not. That can be simplified by caching the condition in an internal status flag, which is updated when one of the relevant inputs changes. The irq_desc::kstat_irq check is dropped because visible interrupt descriptors always have a valid pointer. As a result the number of instructions and branches for reading /proc/interrupts is reduced significantly. Signed-off-by: Thomas Gleixner Tested-by: Michael Kelley Reviewed-by: Dmitry Ilvokhin Reviewed-by: Radu Rendec Link: https://patch.msgid.link/20260517194931.680943749@kernel.org --- include/linux/irq.h | 1 + kernel/irq/chip.c | 2 ++ kernel/irq/internals.h | 2 ++ kernel/irq/manage.c | 8 +++++++- kernel/irq/proc.c | 15 +++++++++++---- kernel/irq/settings.h | 13 +++++++++++++ 6 files changed, 36 insertions(+), 5 deletions(-) diff --git a/include/linux/irq.h b/include/linux/irq.h index efa514e..f485369 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -103,6 +103,7 @@ enum { IRQ_DISABLE_UNLAZY =3D (1 << 19), IRQ_HIDDEN =3D (1 << 20), IRQ_NO_DEBUG =3D (1 << 21), + IRQ_RESERVED =3D (1 << 22), }; =20 #define IRQF_MODIFY_MASK \ diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index 6c9b1dc..2d283d1 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -1007,6 +1007,7 @@ __irq_do_set_handler(struct irq_desc *desc, irq_flow_= handler_t handle, WARN_ON(irq_chip_pm_get(irq_desc_get_irq_data(desc))); irq_activate_and_startup(desc, IRQ_RESEND); } + irq_proc_update_valid(desc); } =20 void __irq_set_handler(unsigned int irq, irq_flow_handler_t handle, int is= _chained, @@ -1067,6 +1068,7 @@ void irq_modify_status(unsigned int irq, unsigned lon= g clr, unsigned long set) trigger =3D tmp; =20 irqd_set(&desc->irq_data, trigger); + irq_proc_update_valid(desc); } } EXPORT_SYMBOL_GPL(irq_modify_status); diff --git a/kernel/irq/internals.h b/kernel/irq/internals.h index db359ac..e5f3d31 100644 --- a/kernel/irq/internals.h +++ b/kernel/irq/internals.h @@ -123,6 +123,7 @@ extern void register_irq_proc(unsigned int irq, struct = irq_desc *desc); extern void unregister_irq_proc(unsigned int irq, struct irq_desc *desc); extern void register_handler_proc(unsigned int irq, struct irqaction *acti= on); extern void unregister_handler_proc(unsigned int irq, struct irqaction *ac= tion); +void irq_proc_update_valid(struct irq_desc *desc); #else static inline void register_irq_proc(unsigned int irq, struct irq_desc *de= sc) { } static inline void unregister_irq_proc(unsigned int irq, struct irq_desc *= desc) { } @@ -130,6 +131,7 @@ static inline void register_handler_proc(unsigned int i= rq, struct irqaction *action) { } static inline void unregister_handler_proc(unsigned int irq, struct irqaction *action) { } +static inline void irq_proc_update_valid(struct irq_desc *desc) { } #endif =20 extern bool irq_can_set_affinity_usr(unsigned int irq); diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 8863b2d..7eb07e3 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -1802,6 +1802,7 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, = struct irqaction *new) __enable_irq(desc); } =20 + irq_proc_update_valid(desc); raw_spin_unlock_irqrestore(&desc->lock, flags); chip_bus_sync_unlock(desc); mutex_unlock(&desc->request_mutex); @@ -1906,6 +1907,7 @@ static struct irqaction *__free_irq(struct irq_desc *= desc, void *dev_id) desc->affinity_hint =3D NULL; #endif =20 + irq_proc_update_valid(desc); raw_spin_unlock_irqrestore(&desc->lock, flags); /* * Drop bus_lock here so the changes which were done in the chip @@ -2047,6 +2049,8 @@ static const void *__cleanup_nmi(unsigned int irq, st= ruct irq_desc *desc) irq_shutdown_and_deactivate(desc); } =20 + irq_proc_update_valid(desc); + if (action) unregister_handler_proc(irq, action); kfree(action); @@ -2433,8 +2437,10 @@ static struct irqaction *__free_percpu_irq(unsigned = int irq, void __percpu *dev_ *action_ptr =3D action->next; =20 /* Demote from NMI if we killed the last action */ - if (!desc->action) + if (!desc->action) { desc->istate &=3D ~IRQS_NMI; + irq_proc_update_valid(desc); + } } =20 unregister_handler_proc(irq, action); diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c index d5b8126..cc9c7c9 100644 --- a/kernel/irq/proc.c +++ b/kernel/irq/proc.c @@ -440,6 +440,16 @@ void init_irq_proc(void) register_irq_proc(irq, desc); } =20 +void irq_proc_update_valid(struct irq_desc *desc) +{ + u32 set =3D _IRQ_PROC_VALID; + + if (irq_settings_is_hidden(desc) || irq_desc_is_chained(desc) || !desc->a= ction) + set =3D 0; + + irq_settings_update_proc_valid(desc, set); +} + #ifdef CONFIG_GENERIC_IRQ_SHOW =20 int __weak arch_show_interrupts(struct seq_file *p, int prec) @@ -516,10 +526,7 @@ int show_interrupts(struct seq_file *p, void *v) =20 guard(rcu)(); desc =3D irq_to_desc(i); - if (!desc || irq_settings_is_hidden(desc)) - return 0; - - if (!desc->action || irq_desc_is_chained(desc) || !desc->kstat_irqs) + if (!desc || !irq_settings_proc_valid(desc)) return 0; =20 seq_printf(p, "%*d:", prec, i); diff --git a/kernel/irq/settings.h b/kernel/irq/settings.h index 00b3bd1..0a0c027 100644 --- a/kernel/irq/settings.h +++ b/kernel/irq/settings.h @@ -18,6 +18,7 @@ enum { _IRQ_DISABLE_UNLAZY =3D IRQ_DISABLE_UNLAZY, _IRQ_HIDDEN =3D IRQ_HIDDEN, _IRQ_NO_DEBUG =3D IRQ_NO_DEBUG, + _IRQ_PROC_VALID =3D IRQ_RESERVED, _IRQF_MODIFY_MASK =3D IRQF_MODIFY_MASK, }; =20 @@ -34,6 +35,7 @@ enum { #define IRQ_DISABLE_UNLAZY GOT_YOU_MORON #define IRQ_HIDDEN GOT_YOU_MORON #define IRQ_NO_DEBUG GOT_YOU_MORON +#define IRQ_RESERVED GOT_YOU_MORON #undef IRQF_MODIFY_MASK #define IRQF_MODIFY_MASK GOT_YOU_MORON =20 @@ -180,3 +182,14 @@ static inline bool irq_settings_no_debug(struct irq_de= sc *desc) { return desc->status_use_accessors & _IRQ_NO_DEBUG; } + +static inline bool irq_settings_proc_valid(struct irq_desc *desc) +{ + return desc->status_use_accessors & _IRQ_PROC_VALID; +} + +static inline void irq_settings_update_proc_valid(struct irq_desc *desc, u= 32 set) +{ + desc->status_use_accessors &=3D ~_IRQ_PROC_VALID; + desc->status_use_accessors |=3D (set & _IRQ_PROC_VALID); +}