IRQ Tracing
irqtracing collects softirq call stacks on all CPUs or a selected CPU and generates flame graphs. source identifies what triggered the softirq; victim identifies the task directly preempted by it. When ksoftirqd handles the softirq, it is the executor and is not recorded as a victim.
The tool can produce local output independently or be invoked by huatuo-bamai through AutoTracing.IRQTracing. Local output requires no storage backend or configuration file.
Build
The standard project build discovers cmd/irqtracing and compiles bpf/irqtracing.c automatically:
make build
The binary is written to _output/bin/irqtracing and the BPF object to _output/bpf/irqtracing.o. Specify the object with --bpf-path at runtime.
Run
sudo ./_output/bin/irqtracing \
--bpf-path ./_output/bpf/irqtracing.o \
--duration 5 \
--output-format collapsed --output-path irqtracing.folded
The optional --cpu-list traces all CPUs when omitted or empty. Currently only one CPU is supported, for example --cpu-list 1; lists or ranges resolving to multiple CPUs return an unsupported error. The tool attaches only to the irq/softirq_raise and irq/softirq_entry tracepoints. All-CPU mode aggregates sources and directly preempted victims across CPUs; a single CPU ID retains only that CPU’s data. Both modes collect for --duration seconds (default: 3).
The optional --max-events-per-second-per-cpu N limits the total source and victim stack samples collected per tracked CPU per second. Omitting it or setting it to 0 disables the limit. When enabled, N must be between 2 and 8589934590. The per-CPU budget is split as evenly as possible between softirq_raise and softirq_entry; for odd budgets, raise gets the extra sample. In all-CPU mode, the system-wide budget grows with the number of tracked CPUs.
Output
Explicitly specify both --output-path and --output-format. Supported formats are collapsed (the default shown in help), flamegraph, svg, json, and remote-store. Local results go to the specified file, directory, or stdout. With stdout, terminals, redirection, or log systems may retain collected data. A nonexistent path is treated as a new file unless it ends with /, which creates a directory. collapsed emits folded stacks for flame graph tools:
source;source[raiser,NET_RX];raise_softirq_[k] 12
victim;victim[worker(123),NET_RX];work 4
Use --output-format flamegraph or --output-format svg to produce an SVG flame graph directly:
sudo ./_output/bin/irqtracing \
--bpf-path ./_output/bpf/irqtracing.o \
--duration 5 \
--output-format flamegraph --output-path irqtracing.svg
The shared collection framework logs a warning when a window contains dropped samples, including the task ID and counts by reason. IRQ logs at warning level or above go to stderr; results go to the specified destination. Failure to write diagnostic logs does not prevent data export.
Remote Storage
To upload a standard profile and dropped-sample counts, use remote-store with a toolstream Unix socket and a unique task ID:
sudo ./_output/bin/irqtracing \
--bpf-path ./_output/bpf/irqtracing.o \
--duration 5 \
--output-format remote-store --output-path /var/run/huatuo-toolstream.sock \
--task-id irq-demo-1
JSON
Use --output-format json --output-path irqtracing.json to save the same window data locally. JSON content:
{
"profile_type": "irqtracing:irq:count:irq:count",
"profile": {
"time_nanos": 1790000000000000000,
"duration_nanos": 3000000000,
"sample_type": [{"type": 1, "unit": 2}],
"string_table": ["", "irq", "count"]
},
"dropped_samples": {"collection": 1234}
}
profile uses pprof format with these sample labels:
| Label | Meaning |
|---|---|
irq_type |
Currently softirq; hardirq is reserved for future hardware interrupt collection |
irq_vector |
Currently the softirq vector number, as a decimal string without leading zeros |
irq_context |
source is the context at raise; victim is the directly preempted task’s context |
cpu |
Host logical CPU ID at sampling |
pid, comm |
Process ID (TGID) and current task name at sampling; source does not establish business ownership |
Display formats map irq_vector to names such as NET_RX only for irq_type=softirq;
storage and queries retain the numeric string. Kernel frames use the _[k] suffix.
New results replace irq and softirq_vector with irq_context and irq_vector.
Historical data is unchanged; queries for those results still use the original labels.
dropped_samples.collection combines losses from rate limiting and counts-map
write failures without distinguishing their causes. Nonzero values indicate
incomplete results; unreadable counters fail collection. Zero values may be omitted.
aggregation_queue is retained only for historical data compatibility.
Profile the tool’s Go runtime
--enable-pprof defaults to false. Enable it to listen on 127.0.0.1:6000; an occupied port fails startup. These profiles describe the irqtracing process itself, not IRQ/softIRQ stacks or huatuo-bamai. Keep the tool running throughout collection.
Invocation by huatuo-bamai
When its rules detect a spike or sustained high irq/softirq utilization on a CPU, the daemon’s AutoTracing.IRQTracing tracer invokes the irqtracing binary beside the daemon executable. CoreBinDir is derived from the daemon’s path; in a source build, the tool is _output/bin/irqtracing.
It passes --bpf-path <CoreBpfDir>/irqtracing.o, --cpu-list <cpu>, --duration <RunTracingToolTimeout>, and --max-events-per-second-per-cpu <MaxEventsPerSecond>. MaxEventsPerSecond defaults to 1000, giving raise and entry a default limit of 500/s each.
This path requires Elasticsearch configuration. Tracing local-file storage alone cannot save IRQ profiles. Trigger rules and the triggering CPU’s utilization are recorded in daemon logs.
Results and Compatibility
IRQ results are written to profile_data in profiling storage with tracer_name=irqtracing and tracer_type=profiling. Query them through the profiling API using irqtracing:irq:count:irq:count. Historical tracing documents remain accessible through the original tracing queries and are not rewritten. The old flamedata/nmissed transport format has been removed; protocol version 3 requires the CLI and daemon to be upgraded together.
Completion
A task succeeds only after the profile is queryable, publication succeeds, and the tool receives the daemon’s acknowledgment. Ending data transmission alone, collection failure, or disconnection does not publish a task completion marker. If the acknowledgment is lost, results may already be published; query by task ID to confirm. See Profiling Window Commit for implementation details.
Collect through the API
Use the Profiling API to collect softirq stacks on all CPUs and query tasks and results.