Skip to content

proc/stat: Maintain monotonicity of "intr" and "softirq"

Alexei Lozovsky linux-fsdevel lkml 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest12 patches 0 repliesNew
  2. v17 patches 5 repliesSuperseded

Changes in v2 from the cover letter

- Added READ_ONCE to all reads of per-CPU counters
- Widened and unified all counters to "unsigned long" instead of clamping them all to "unsigned int"
- Fixed typos in documentation

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/12genirq: Use READ_ONCE for IRQ counter readsinclude/linux/kernel_stat.h+2 -20 replies
2/12genirq: Use unsigned long for IRQ countersfs/proc/softirqs.c fs/proc/stat.c include/linux/kernel_stat.h +2 more+8 -80 replies
3/12powerpc/irq: Use READ_ONCE for IRQ counter readsarch/powerpc/kernel/irq.c+20 -200 replies
4/12powerpc/irq: Use unsigned long for IRQ countersarch/powerpc/include/asm/hardirq.h arch/powerpc/include/asm/paca.h arch/powerpc/kernel/irq.c+20 -200 replies
5/12powerpc/irq: Use unsigned long for IRQ counter sumarch/powerpc/include/asm/hardirq.h arch/powerpc/kernel/irq.c+3 -30 replies
6/12x86/irq: Use READ_ONCE for IRQ counter readsarch/x86/kernel/irq.c+35 -340 replies
7/12x86/irq: Use unsigned long for IRQ countersarch/x86/include/asm/hardirq.h arch/x86/include/asm/mce.h arch/x86/kernel/cpu/mce/core.c +1 more+28 -280 replies
8/12x86/irq: Use unsigned long for IRQ counters morearch/x86/include/asm/hw_irq.h arch/x86/kernel/apic/apic.c arch/x86/kernel/apic/io_apic.c +2 more+10 -100 replies
9/12x86/irq: Use unsigned long for IRQ counter sumarch/x86/include/asm/hardirq.h arch/x86/kernel/irq.c+6 -70 replies
10/12proc/stat: Use unsigned long for "intr" sumfs/proc/stat.c+2 -20 replies
11/12proc/stat: Use unsigned long for "softirq" sumfs/proc/stat.c+3 -30 replies
12/12docs: proc.rst: stat: Note the interrupt counter wrap-aroundDocumentation/filesystems/proc.rst+8 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 00/12] proc/stat: Maintain monotonicity of "intr" and "softirq"

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.

The total counters are not actually maintained but computed from individual counters. These counters must all have the same width for their sum to wrap around in correct and expected manner.

This patch set unifies all counters that are displayed by /proc/stat and /proc/interrupts to use "unsigned long" (instead of "unsigned int" values that get summed into u64, which causes problems for userspace monitoring tools when the individual counters wrap around).

v1 -> v2:

- Added READ_ONCE to all reads of per-CPU counters
- Widened and unified all counters to "unsigned long" instead of clamping them all to "unsigned int"
- Fixed typos in documentation

Since the scope of changes has expanded, I think these patches will need to be seen and vetted by more people (get-maintainer.pl agrees) but for now I'll keep the same CC list as for v1.

Unresolved questions:

- Does READ_ONCE addition has any merit without WRITE_ONCE?

- Some counters turned out to be unaccounted for in the total sum. Should they be included there? Or are they omitted on purpose?

- I haven't tested this on PowerPC since I don't have the hardware

Alexei Lozovsky (12):
genirq: Use READ_ONCE for IRQ counter reads
genirq: Use unsigned long for IRQ counters powerpc/irq: Use READ_ONCE for IRQ counter reads powerpc/irq: Use unsigned long for IRQ counters powerpc/irq: Use unsigned long for IRQ counter sum x86/irq: Use READ_ONCE for IRQ counter reads x86/irq: Use unsigned long for IRQ counters x86/irq: Use unsigned long for IRQ counters more x86/irq: Use unsigned long for IRQ counter sum proc/stat: Use unsigned long for "intr" sum proc/stat: Use unsigned long for "softirq" sum
docs: proc.rst: stat: Note the interrupt counter wrap-around

 Documentation/filesystems/proc.rst |  8 +++
 arch/powerpc/include/asm/hardirq.h | 20 ++++----
 arch/powerpc/include/asm/paca.h    |  2 +-
 arch/powerpc/kernel/irq.c          | 42 +++++++--------
 arch/x86/include/asm/hardirq.h     | 26 +++++-----
 arch/x86/include/asm/hw_irq.h      |  4 +-
 arch/x86/include/asm/mce.h         |  4 +-
 arch/x86/kernel/apic/apic.c        |  2 +-
 arch/x86/kernel/apic/io_apic.c     |  4 +-
 arch/x86/kernel/cpu/mce/core.c     |  4 +-
 arch/x86/kernel/i8259.c            |  2 +-
 arch/x86/kernel/irq.c              | 82 +++++++++++++++---------------
 fs/proc/softirqs.c                 |  2 +-
 fs/proc/stat.c                     | 12 ++---
 include/linux/kernel_stat.h        | 10 ++--
 kernel/rcu/tree.h                  |  2 +-
 kernel/rcu/tree_stall.h            |  4 +-
 17 files changed, 119 insertions(+), 111 deletions(-)
Signature · 1 line
2.25.1