fix proc interrupts name parsing#22556
fix proc interrupts name parsing#22556stelfrag merged 3 commits intonetdata:masternetdata/netdata:masterfrom Kelpy2004:fix-proc-interrupt-namesKelpy2004/netdata:fix-proc-interrupt-namesCopy head branch name to clipboard
Conversation
There was a problem hiding this comment.
No issues found across 3 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Architecture diagram
sequenceDiagram
participant Plugin as proc.plugin
participant File as /proc/interrupts
participant Parser as Interrupt Parser
participant NameBuilder as Name Builder
participant RRD as Netdata DB
participant UnitTest as Unit Test Runner
Note over Plugin,RRD: /proc/interrupts collection flow
Plugin->>File: open() with separator " \t" (no colon)
File-->>Plugin: raw line data
Plugin->>Parser: parse each line
loop per interrupt line
Parser->>Parser: extract IRQ id (first token)
Parser->>Parser: skip CPU columns (CPU0, CPU1...)
Parser->>Parser: skip interrupt controller metadata (trigger type, chip info)
Parser->>NameBuilder: build name from remaining tokens
Note over NameBuilder: Normalize spaces and colons to underscores
NameBuilder->>NameBuilder: concatenate tokens with '_'
NameBuilder->>NameBuilder: append IRQ id with '_' suffix
NameBuilder-->>Parser: full dimension name
alt line has numeric IRQ
Parser->>RRD: create chart dimension "name_ID"
else non-numeric IRQ (e.g., "NMI")
Parser->>RRD: use IRQ id as dimension name
end
end
Note over UnitTest,NameBuilder: Regression test flow (Linux only)
UnitTest->>File: create temp fixture file
UnitTest->>Plugin: proc_interrupts_unittest()
Plugin->>File: procfile_open() with " \t" separator
File-->>Plugin: fixture content
Plugin->>Parser: parse known patterns (PCI/MSI, NVMe, timer, etc.)
Parser->>NameBuilder: build names
NameBuilder-->>Parser: normalized names
Parser-->>Plugin: compare against expected values
alt match expected
Plugin-->>UnitTest: pass (return 0)
else mismatch
Plugin-->>UnitTest: fail (return 1)
end
Note over NameBuilder: Key examples after normalization:
Note over NameBuilder: "mlx5_comp40@pci:0000:86:00.0" + IRQ 240
Note over NameBuilder: → "mlx5_comp40@pci_0000_86_00.0_240"
Note over NameBuilder: "nvme 0 io5" + IRQ 250
Note over NameBuilder: → "nvme_0_io5_250"
defd25b to
e6aa0ba
Compare
|
Hi @vkalintiris @thiagoftsm , just checking if you have any thoughts on this when you get a chance. The CI checks are green now. |
There was a problem hiding this comment.
Pull request overview
This PR fixes Linux /proc/interrupts parsing in proc.plugin so interrupt dimension names are derived from the full action-name portion of each line (instead of being truncated when names contain : or spaces). It also adds Linux-only regression coverage to prevent the issue from recurring.
Changes:
- Stop tokenizing
/proc/interruptslines on:and build the interrupt dimension name from the full action-name portion, normalizing:and whitespace to_while preserving the existing IRQ suffix behavior. - Add bounds-safe helpers for word access and name construction to avoid relying on fragile indexing assumptions.
- Add a Linux regression unit test (
proc_interrupts_unittest()) and wire it intorun_all_mockup_tests()behindOS_LINUX.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/daemon/unit_test.c |
Runs the new /proc/interrupts parsing regression test on Linux in the existing mockup test suite. |
src/collectors/proc.plugin/proc_interrupts.c |
Fixes the parsing logic to keep full interrupt source names and adds a Linux unit test for the reported cases. |
src/collectors/proc.plugin/plugin_proc.h |
Exposes proc_interrupts_unittest() so it can be invoked from the Linux test runner. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e6aa0ba to
161efd1
Compare
thiagoftsm
left a comment
There was a problem hiding this comment.
Testing on Alma 9 the interrupts are appearing as expected. No issues happen during runtime or shutdown.
I identified an issue with our dictionaries when running unit-tests, but they are not associated with this PR. Thus, LGTM!
|
Resolved the conflict by keeping both proc_interrupts_unittest() and test_incremental_sum_lookup_respects_update_every(). The actual proc interrupts fix is unchanged. |
|
|
Thanks for the review. |
|
@Kelpy2004, thanks for the fix 👍 |
Summary
Fixes #22532
This PR fixes
/proc/interruptsname parsing inproc.plugin.Previously, the collector treated
:as a procfile separator and used only the last parsed token as the interrupt action name. This caused interrupt dimension names to be shortened incorrectly when the source name contained colons or spaces.Examples of the broken behavior:
mlx5_comp40@pci:0000:86:00.0could become00.0_240nvme 0 io5could becomeio5_250This change builds the dimension name from the full interrupt action-name portion of the
/proc/interruptsline. Spaces and:are normalized to_, and the existing IRQ suffix behavior is preserved.Expected examples after this change:
mlx5_comp40@pci:0000:86:00.0with IRQ240becomesmlx5_comp40@pci_0000_86_00.0_240nvme 0 io5with IRQ250becomesnvme_0_io5_250Test Plan
Added regression coverage through
proc_interrupts_unittest().The test fixture covers the reported cases:
mlx5_comp40@pci:0000:86:00.0nvme 0 io5It also covers existing simpler interrupt-name patterns:
timerkeyboardarch_timerThe unittest is wired into
run_all_mockup_tests()behindOS_LINUX, since/proc/interruptsparsing is Linux-specific.Additional Information
This is a focused parser fix for the Linux
/proc/interruptscollector.The issue was caused by tokenizing interrupt lines in a way that split PCI-style names on
:and then selected only the last token as the interrupt name. The updated parser keeps the full action-name portion, skips interrupt-controller metadata, normalizes the resulting name for use as a Netdata dimension name, and appends the IRQ id as before.For users: How does this change affect me?
This affects Netdata's Linux
/proc/interruptscollector.Users may see clearer and more complete interrupt dimension names in interrupt charts, especially for PCI/MSI and NVMe interrupt sources.
For example, instead of shortened names such as
00.0_240orio5_250, users should see normalized names that preserve the full interrupt source, such asmlx5_comp40@pci_0000_86_00.0_240andnvme_0_io5_250.This makes interrupt charts easier to understand and helps users identify the actual hardware device or queue associated with an interrupt.
Summary by cubic
Fix
/proc/interruptsparsing inproc.pluginto keep full interrupt source names and produce stable, readable dimension names. Prevents truncated PCI/NVMe names in charts and adds a Linux regression test.:as part of words; split only on spaces/tabs.-edge); normalize spaces/:to a single_(no double_); keep the IRQ suffix.memfd_create, wired intorun_all_mockup_tests(), covering PCI/MSI, NVMe, and simple sources.Written for commit a23ac65. Summary will update on new commits.
Review in cubic