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 282563BE15A for ; Tue, 31 Mar 2026 07:25:43 +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=1774941944; cv=none; b=c+xoUA9GfrFYeNhMhtCAO6IBzOZ2n31MMooQ0ZiXb7kAD/M/fzzm9T0rcCFyVT1B2d32J285EBG5NeJWpzyjpE7/Js3eJGxp1y9rdqTBebLsgow1LGl3JqxYcGjysfySXEkhGJTX7VS6Lerl4T1rJaagVZtHUueeLj4oq0ExJZs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774941944; c=relaxed/simple; bh=aGrsXvBSJ0xJJltwn7h8IlI4R1qNBcKQypDL5gT+R7U=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=W6q/YiPIQh05W/1s8bYGdupDwLs9y8Lv6ZkpmkDF75S/GJU7MYQC/kLdRjj1Ylr/Cmm3j038sDLapolnRNl9YSV5zLYqbtTim9rMRHuxBML7WZXgJpr2unkcOIT2BM5fmBSM3ZG+d+Jgd/LAOv8zTE8ZttwpjY5c0K/oW+DhZYY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GcyEjNaX; 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="GcyEjNaX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 069CAC2BCB0; Tue, 31 Mar 2026 07:25:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774941943; bh=aGrsXvBSJ0xJJltwn7h8IlI4R1qNBcKQypDL5gT+R7U=; h=Date:From:To:Cc:Subject:References:From; b=GcyEjNaXnDKCVFXubYbot6E0cSGLtgxV24ORmifKPC1+i+6CXooVTHSrGVtlUHQ/C DAQXcvR8P92Y7FX2dRPmK2WGQ94F8e/v+Km8B81oSgB1QLe04Hk1etcfeCVyqoMa0g ro6lrubCrXjfxVM5OScCsd+Rb/YthsjxI0eCvgZYFc9gkLULu5rKabfOUPWc+btGrQ DXwH2TOpYi3yb7MfDBZcKpq5Bqg3GXbB+Wm14/JqP0I+9tGiTtOqLSrO5ggsDuAu74 d8GrqilpXyMw+jsmmz94S7RAgfksi9+aQpYVoJZ+28sRDhdI1mBjiSe+6XAnFoidBq 6JM8hVKzErBPQ== Date: Tue, 31 Mar 2026 09:25:40 +0200 Message-ID: <20260331072418.745325369@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 03/15] genirq/proc: Utilize irq_desc::tot_count to avoid evaluation 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 Interrupts which are not marked per CPU increment not only the per CPU statistics, but also the accumulation counter irq_desc::tot_count. Change the counter to type unsigned long so it does not produce sporadic zeros due to wrap arounds on 64-bit machines and do a quick check for non per CPU interrupts. If the counter is zero, then simply emit a full set of zero strings. That spares the evaluation of the per CPU counters completely for interrupts with zero events. Signed-off-by: Thomas Gleixner Reviewed-by: Dmitry Ilvokhin Reviewed-by: Radu Rendec --- include/linux/irqdesc.h | 6 +++--- kernel/irq/proc.c | 11 ++++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) --- a/include/linux/irqdesc.h +++ b/include/linux/irqdesc.h @@ -52,8 +52,8 @@ struct irq_redirect { * @depth: disable-depth, for nested irq_disable() calls * @wake_depth: enable depth, for multiple irq_set_irq_wake() callers * @tot_count: stats field for non-percpu irqs - * @irq_count: stats field to detect stalled irqs * @last_unhandled: aging timer for unhandled count + * @irq_count: stats field to detect stalled irqs * @irqs_unhandled: stats field for spurious unhandled interrupts * @threads_handled: stats field for deferred spurious detection of threaded handlers * @threads_handled_last: comparator field for deferred spurious detection of threaded handlers @@ -87,9 +87,9 @@ struct irq_desc { unsigned int core_internal_state__do_not_mess_with_it; unsigned int depth; /* nested irq disables */ unsigned int wake_depth; /* nested wake enables */ - unsigned int tot_count; - unsigned int irq_count; /* For detecting broken IRQs */ + unsigned long tot_count; unsigned long last_unhandled; /* Aging timer for unhandled count */ + unsigned int irq_count; /* For detecting broken IRQs */ unsigned int irqs_unhandled; atomic_t threads_handled; int threads_handled_last; --- a/kernel/irq/proc.c +++ b/kernel/irq/proc.c @@ -521,7 +521,16 @@ int show_interrupts(struct seq_file *p, return 0; seq_printf(p, "%*d:", prec, i); - irq_proc_emit_counts(p, &desc->kstat_irqs->cnt); + + /* + * Always output per CPU interrupts. Output device interrupts only when + * desc::tot_count is not zero. + */ + if (irq_settings_is_per_cpu(desc) || irq_settings_is_per_cpu_devid(desc) || + data_race(desc->tot_count)) + irq_proc_emit_counts(p, &desc->kstat_irqs->cnt); + else + irq_proc_emit_zero_counts(p, num_online_cpus()); seq_putc(p, ' '); guard(raw_spinlock_irq)(&desc->lock);