[PATCH 0/7] proc/stat: Maintain monotonicity of "intr" and "softirq"

From: Alexei Lozovsky
Date: Fri Sep 10 2021 - 23:48:21 EST


Here's a patch set that makes /proc/stat report total interrupt counts
as monotonically increasing values, just like individual counters for
interrupt types and CPUs are.

This is as if the sum was a shared counter that all CPUs increment
atomically together with their individual counters, with the sum
correctly and expectedly wrapping around to zero once it reaches
UINT_MAX.

I've also added some documentation bits to codify this behavior and make
it explicit that wrap-arounds must be expected and handled if userspace
wants to maintain accurate total interrupt count for whatever reasons.

Alexei Lozovsky (7):
genirq: Use unsigned int for irqs_sum
powerpc/irq: arch_irq_stat_cpu() returns unsigned int
x86/irq: arch_irq_stat_cpu() returns unsigned int
x86/irq: arch_irq_stat() returns unsigned int
proc/stat: Use unsigned int for "intr" sum
proc/stat: Use unsigned int for "softirq" sum
docs: proc.rst: stat: Note the interrupt counter wrap-around

Documentation/filesystems/proc.rst | 7 +++++++
arch/powerpc/include/asm/hardirq.h | 2 +-
arch/powerpc/kernel/irq.c | 4 ++--
arch/x86/include/asm/hardirq.h | 4 ++--
arch/x86/kernel/irq.c | 8 ++++----
fs/proc/stat.c | 8 ++++----
include/linux/kernel_stat.h | 2 +-
7 files changed, 21 insertions(+), 14 deletions(-)

--
2.25.1