From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 12818321F5E for ; Thu, 26 Mar 2026 21:57:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774562222; cv=none; b=UQ3vGvTZySjbXf8NNajq/R1JvXIPb79Mh4Ml4IE+ZRsKMjTvZGiWiPY2pZCHhmyE2X7U+aWLEQK3FZiAMmZ8DTOxMP7qlHqiLtwZPWj05AANXAUts5jS3hESfOzS5wxN1cq0GIG3Vd+bp47BdNG8zdqBDADM01JQtWl+Ch1y78w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774562222; c=relaxed/simple; bh=pHd/7lEwhdBQIyYNXhn4ou2RhdMH1y2ZI4ud6M+apfQ=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=taRezP3Ggt0PatCxM6yqWtTZkp2XRvdtEuSAidIErY8lcexDceRMIGZorzD2UIwdEx+SDdurRH2i53SNWW5n29+xhgsc/lU2VS9D+6A6fm6GnLAiHkBn8KKfzCYTKD/jakBOJK4n6zuuaYTZP8k2gtC+gexg3wwyJKrVyTswJ/8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PUPQBWcj; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PUPQBWcj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12791C2BCB1; Thu, 26 Mar 2026 21:57:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774562221; bh=pHd/7lEwhdBQIyYNXhn4ou2RhdMH1y2ZI4ud6M+apfQ=; h=Date:From:To:Cc:Subject:References:From; b=PUPQBWcjPkMzxo1z8boMwYla2VPNANB1irNl5PQnHt+SpAAZEn1Oi2P5mCT44sNiD FCkTYLPbVx2h3dFNQFgXvGmXYyP1fWZg2wPor2YcvQ6+KGcvGFZl7lVgcVTuYWdHE1 kKrWQRvg7MX7L1ilDYM0/lVxXgzib/dsnbB9UpvPhGdROvc74Dn0By/VFe3IVciyEx u2roRoHwcxm/mEBwBk+1mBCe4Olutf93tgsCBOxLOqX7QEHCOuCJqKugokH6FUUK4A To2xRwMIgLcU2CYbgWdVzIQEjZ0uFwp8sI4QZXQY72cxtHs1R1KthqxV4LWNNPmuMa /CuD0NKXc90GA== Date: Thu, 26 Mar 2026 22:56:57 +0100 Message-ID: <20260326215036.578625795@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Michael Kelley , Dmitry Ilvokhin , Radu Rendec , Jan Kiszka , Kieran Bingham , Florian Fainelli Subject: [patch V3 05/14] x86/irq: Suppress unlikely interrupt stats by default References: <20260326214345.019130211@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Unlikely interrupt counters like the spurious vector and the synthetic APIC ICR read retry show up in /proc/interrupts with all counts 0 most of the time. As these are events which should never happen, suppress them by default and enable them for output when they actually happen. Signed-off-by: Thomas Gleixner --- V3: New patch --- arch/x86/include/asm/hardirq.h | 1 + arch/x86/kernel/apic/apic.c | 2 +- arch/x86/kernel/apic/ipi.c | 2 +- arch/x86/kernel/irq.c | 25 +++++++++++++++++++++---- 4 files changed, 24 insertions(+), 6 deletions(-) --- a/arch/x86/include/asm/hardirq.h +++ b/arch/x86/include/asm/hardirq.h @@ -68,6 +68,7 @@ DECLARE_PER_CPU_ALIGNED(struct pi_desc, #define __ARCH_IRQ_STAT #define inc_irq_stat(index) this_cpu_inc(irq_stat.counts[IRQ_COUNT_##index]) +void irq_stat_inc_and_enable(enum irq_stat_counts which); #ifdef CONFIG_X86_LOCAL_APIC #define inc_perf_irq_stat() inc_irq_stat(APIC_PERF) --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -2108,7 +2108,7 @@ static noinline void handle_spurious_int trace_spurious_apic_entry(vector); - inc_irq_stat(SPURIOUS); + irq_stat_inc_and_enable(IRQ_COUNT_SPURIOUS); /* * If this is a spurious interrupt then do not acknowledge --- a/arch/x86/kernel/apic/ipi.c +++ b/arch/x86/kernel/apic/ipi.c @@ -120,7 +120,7 @@ u32 apic_mem_wait_icr_idle_timeout(void) for (cnt = 0; cnt < 1000; cnt++) { if (!(apic_read(APIC_ICR) & APIC_ICR_BUSY)) return 0; - inc_irq_stat(ICR_READ_RETRY); + irq_stat_inc_and_enable(IRQ_COUNT_ICR_READ_RETRY); udelay(100); } return APIC_ICR_BUSY; --- a/arch/x86/kernel/irq.c +++ b/arch/x86/kernel/irq.c @@ -68,19 +68,24 @@ struct irq_stat_info { const char *text; }; +#define DEFAULT_SUPPRESSED_VECTOR UINT_MAX + #define ISS(idx, sym, txt) [IRQ_COUNT_##idx] = { .symbol = sym, .text = txt } #define ITS(idx, sym, txt) [IRQ_COUNT_##idx] = \ { .skip_vector = idx## _VECTOR, .symbol = sym, .text = txt } +#define IDS(idx, sym, txt) [IRQ_COUNT_##idx] = \ + { .skip_vector = DEFAULT_SUPPRESSED_VECTOR, .symbol = sym, .text = txt } + static struct irq_stat_info irq_stat_info[IRQ_COUNT_MAX] __ro_after_init = { ISS(NMI, "NMI", " Non-maskable interrupts\n"), #ifdef CONFIG_X86_LOCAL_APIC ISS(APIC_TIMER, "LOC", " Local timer interrupts\n"), - ISS(SPURIOUS, "SPU", " Spurious interrupts\n"), + IDS(SPURIOUS, "SPU", " Spurious interrupts\n"), ISS(APIC_PERF, "PMI", " Performance monitoring interrupts\n"), ISS(IRQ_WORK, "IWI", " IRQ work interrupts\n"), - ISS(ICR_READ_RETRY, "RTR", " APIC ICR read retries\n"), + IDS(ICR_READ_RETRY, "RTR", " APIC ICR read retries\n"), ISS(X86_PLATFORM_IPI, "PLT", " Platform interrupts\n"), #endif #ifdef CONFIG_SMP @@ -126,7 +131,8 @@ void __init irq_init_stats(void) struct irq_stat_info *info = irq_stat_info; for (unsigned int i = 0; i < ARRAY_SIZE(irq_stat_info); i++, info++) { - if (info->skip_vector && test_bit(info->skip_vector, system_vectors)) + if (info->skip_vector && info->skip_vector != DEFAULT_SUPPRESSED_VECTOR && + test_bit(info->skip_vector, system_vectors)) info->skip_vector = 0; } @@ -141,6 +147,17 @@ void __init irq_init_stats(void) #endif } +/* + * Used for default enabled counters to increment the stats and to enable the + * entry for /proc/interrupts output. + */ +void irq_stat_inc_and_enable(enum irq_stat_counts which) +{ + this_cpu_inc(irq_stat.counts[which]); + /* Pairs with the READ_ONCE() in arch_show_interrupts() */ + WRITE_ONCE(irq_stat_info[which].skip_vector, 0); +} + #ifdef CONFIG_PROC_FS /* * /proc/interrupts printing for arch specific interrupts @@ -150,7 +167,7 @@ int arch_show_interrupts(struct seq_file const struct irq_stat_info *info = irq_stat_info; for (unsigned int i = 0; i < ARRAY_SIZE(irq_stat_info); i++, info++) { - if (info->skip_vector) + if (READ_ONCE(info->skip_vector)) continue; seq_printf(p, "%*s:", prec, info->symbol);