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 960073A63F2 for ; Tue, 31 Mar 2026 07:25:54 +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=1774941954; cv=none; b=oAnFTqb/tsVd7wfJK1O3qroWHHJH0dmwPaKf/WRrnQh6yuM95wnTj88d47zh9mPvZ9iVRblBncZPDGSxtH83CfQVeagOlbewi8be5zqhQf2/PD1mJlY/d3FF3DMwSmeobLDAkbw4XROLkhzG15Wyetkx9AIXxu04FaAkvIK8uVA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774941954; c=relaxed/simple; bh=LAhdZYHjVFyMiVhu5h/FvrprZkFT0doj453qeHm3iRo=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=ggb5hddkKpcUbK73wGRHtgmjifzwXZcthpaIKHoHT39wmBR2aLVMTFHCe0hIbe1zpl3WSQ8ejwhVASG7jBAc1/KHegoPSFzCi+TDW0UGZ2EXpeFIU0H2k8tBMIQPypHs3+xtA8l3oB6saZsmY34L8+1/ZASJsP43xXMbZ/dg0E4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=s0WTAyQ0; 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="s0WTAyQ0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4015C2BCB2; Tue, 31 Mar 2026 07:25:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774941954; bh=LAhdZYHjVFyMiVhu5h/FvrprZkFT0doj453qeHm3iRo=; h=Date:From:To:Cc:Subject:References:From; b=s0WTAyQ08drDvVb1ik2UiKdWqvWMA/GzGXp03ZXrHnEd7F4yDtJIssNfiFIe89Hu7 KGt02MOC3VCw8wGJ2NV9h4G+TKBIlDVOvSkWMy7W9j7qSHtNZ9s6Ow8pjqk6dZPcwZ poXWVQ0txbqzhh5UcavwoINKlhrbraQo1Q+toZzDIaytQ/S4HuAWfKtS7qyHUtlMcp I2EjsENWgnkNa7wg0smucMQHycjurWowYonMowzih3M2PAZK+xtQ85gxqE9UQr37um OJwZJJLVpeUTu15z6rgneDK1D6+3Pa5Itv2MSpschHHhq6jXwGXzaycm+W4STUOKrz F0+quq2cgSo6g== Date: Tue, 31 Mar 2026 09:25:51 +0200 Message-ID: <20260331072418.880584661@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 , Marc Zyngier Subject: [patch V4 05/15] x86/irq: Suppress unlikely interrupt stats by default References: <20260331071453.172185305@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 From: Thomas Gleixner 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. This requires a seperate bitmap as the description array is marked __ro_after_init. With that bitmap in place it becomes RO data. Signed-off-by: Thomas Gleixner --- V4: Fix the bad idea of writing to __ro_after_init marked data 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 | 28 ++++++++++++++++++---------- 4 files changed, 21 insertions(+), 12 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 } -static struct irq_stat_info irq_stat_info[IRQ_COUNT_MAX] __ro_after_init = { +#define IDS(idx, sym, txt) [IRQ_COUNT_##idx] = \ + { .skip_vector = DEFAULT_SUPPRESSED_VECTOR, .symbol = sym, .text = txt } + +static const struct irq_stat_info irq_stat_info[IRQ_COUNT_MAX] = { 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 @@ -121,29 +126,32 @@ static struct irq_stat_info irq_stat_inf #endif }; +static DECLARE_BITMAP(irq_stat_count_show, IRQ_COUNT_MAX) __read_mostly; + static int __init irq_init_stats(void) { - struct irq_stat_info *info = irq_stat_info; + 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 && test_bit(info->skip_vector, system_vectors)) - info->skip_vector = 0; + if (!info->skip_vector || (info->skip_vector != DEFAULT_SUPPRESSED_VECTOR && + test_bit(info->skip_vector, system_vectors))) + set_bit(i, irq_stat_count_show); } #ifdef CONFIG_X86_LOCAL_APIC if (!x86_platform_ipi_callback) - irq_stat_info[IRQ_COUNT_X86_PLATFORM_IPI].skip_vector = 1; + clear_bit(IRQ_COUNT_X86_PLATFORM_IPI, irq_stat_count_show); #endif #ifdef CONFIG_X86_POSTED_MSI if (!posted_msi_enabled()) - irq_stat_info[IRQ_COUNT_POSTED_MSI_NOTIFICATION].skip_vector = 1; + clear_bit(IRQ_COUNT_POSTED_MSI_NOTIFICATION, irq_stat_count_show); #endif #ifdef CONFIG_X86_MCE_AMD if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD && boot_cpu_data.x86_vendor != X86_VENDOR_HYGON) - irq_stat_info[IRQ_COUNT_DEFERRED_VECTOR].skip_vector = 1; + clear_bit(IRQ_COUNT_DEFERRED_ERROR, irq_stat_count_show); #endif return 0; } @@ -168,7 +176,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 (!test_bit(i, irq_stat_count_show)) continue; seq_printf(p, "%*s:", prec, info->symbol);