Skip to main content

Module irq_counter

Module irq_counter 

Source
Expand description

A per-thread count of the interrupts the probe thread takes, from the core PMU (https://github.com/rrnewton/hermit/issues/4243), condition C11).

The XINUSE probe’s reference trial is valid only if nothing saved and reloaded the thread’s FPU state inside it. Without a context switch, Linux does that only through kernel_fpu_begin in interrupt or softirq context, or in the task’s own syscall, so a trial that took no interrupt, no context switch and no syscall cannot contain a reload. This counter supplies the interrupt half of that certificate, and every property it rests on is checked rather than assumed:

  • the raw event is used only on CPU models whose perf tables document it;
  • it is opened pinned, so it is never time-shared, and every read checks that its time enabled equals its time running (both are cumulative, so equality at a read proves it counted for its whole enabled history);
  • a failed read is an error, never a value that could compare equal;
  • at startup its count over a spin must bind to the kernel’s own count of this CPU’s interrupts in /proc/interrupts.

Structs§

CpuInterrupts
One CPU’s local-timer count and its column total in /proc/interrupts.
CpuModel
The CPU’s vendor and display family/model, from CPUID leaves 0 and 1.
IrqCounter
An open, pinned interrupts-taken counter for the calling thread.

Enums§

CounterRefusal
Why the counter cannot certify trials on this host.

Constants§

CALIBRATION_SLACK
A fixed allowance on top of the proportional one in calibration_verdict.
MIN_CALIBRATION_TICKS
The fewest local-timer interrupts a calibration must see, summed over its clean spins. CALIBRATION_SLACK is absolute, so this floor is what keeps the binding tight: at 190 interrupts the counter must see at least 180 of them, about 95%, when the reads around the spins take no time. (A single 70 ms spin sees about 70, where the slack alone would admit about 86%.) A tickless (nohz_full) CPU sees almost none, and there the binding says nothing.

Functions§

calibration_verdict
Whether a calibration binds the counter to the kernel’s count: over its clean spins, summed, the counter must see at least this CPU’s local-timer interrupts and no more than all of its interrupts.
interrupts_of
cpu’s interrupt counts from a snapshot_proc_interrupts text.
interrupts_taken_event
The raw PMU configuration of the interrupts-taken event on cpu, or None where perf’s event tables do not document one.
parse_proc_interrupts
Parses /proc/interrupts text for cpu’s column. Rows whose entry in that column is not a number (the trailing descriptions of ERR and MIS) are skipped; the LOC row must be present.
snapshot_proc_interrupts
Reads /proc/interrupts whole. It is about 1.4 MB on a 316-CPU machine; the caller parses it after taking its other samples, so parsing time does not widen the interval the counter must cover.