Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix proc interrupts name parsing#22556

Merged
stelfrag merged 3 commits into
netdata:masternetdata/netdata:masterfrom
Kelpy2004:fix-proc-interrupt-namesKelpy2004/netdata:fix-proc-interrupt-namesCopy head branch name to clipboard
May 28, 2026
Merged

fix proc interrupts name parsing#22556
stelfrag merged 3 commits into
netdata:masternetdata/netdata:masterfrom
Kelpy2004:fix-proc-interrupt-namesKelpy2004/netdata:fix-proc-interrupt-namesCopy head branch name to clipboard

Conversation

@Kelpy2004

@Kelpy2004 Kelpy2004 commented May 24, 2026

Copy link
Copy Markdown
Contributor
Summary

Fixes #22532

This PR fixes /proc/interrupts name parsing in proc.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.0 could become 00.0_240
  • nvme 0 io5 could become io5_250

This change builds the dimension name from the full interrupt action-name portion of the /proc/interrupts line. Spaces and : are normalized to _, and the existing IRQ suffix behavior is preserved.
Expected examples after this change:

  • mlx5_comp40@pci:0000:86:00.0 with IRQ 240 becomes mlx5_comp40@pci_0000_86_00.0_240
  • nvme 0 io5 with IRQ 250 becomes nvme_0_io5_250
Test Plan

Added regression coverage through proc_interrupts_unittest().
The test fixture covers the reported cases:

  • mlx5_comp40@pci:0000:86:00.0
  • nvme 0 io5

It also covers existing simpler interrupt-name patterns:

  • timer
  • keyboard
  • arch_timer
    The unittest is wired into run_all_mockup_tests() behind OS_LINUX, since /proc/interrupts parsing is Linux-specific.
Additional Information

This is a focused parser fix for the Linux /proc/interrupts collector.
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/interrupts collector.
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_240 or io5_250, users should see normalized names that preserve the full interrupt source, such as mlx5_comp40@pci_0000_86_00.0_240 and nvme_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/interrupts parsing in proc.plugin to keep full interrupt source names and produce stable, readable dimension names. Prevents truncated PCI/NVMe names in charts and adds a Linux regression test.

  • Bug Fixes
    • Treat : as part of words; split only on spaces/tabs.
    • Build names from the full action-name; skip controller/chip and trigger columns (edge/level/fasteoi or -edge); normalize spaces/: to a single _ (no double _); keep the IRQ suffix.
    • Add bounds-safe helpers and validations; safer word access; handle missing CPU fields; add a Linux unit test using memfd_create, wired into run_all_mockup_tests(), covering PCI/MSI, NVMe, and simple sources.

Written for commit a23ac65. Summary will update on new commits.

Review in cubic

Comment thread src/collectors/proc.plugin/proc_interrupts.c Fixed

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"
Loading

Re-trigger cubic

@Kelpy2004
Kelpy2004 force-pushed the fix-proc-interrupt-names branch 3 times, most recently from defd25b to e6aa0ba Compare May 24, 2026 12:37
@Kelpy2004

Copy link
Copy Markdown
Contributor Author

Hi @vkalintiris @thiagoftsm , just checking if you have any thoughts on this when you get a chance. The CI checks are green now.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/interrupts lines 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 into run_all_mockup_tests() behind OS_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.

Comment thread src/collectors/proc.plugin/proc_interrupts.c Fixed
@vkalintiris
vkalintiris requested a review from a team May 25, 2026 11:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread src/collectors/proc.plugin/proc_interrupts.c
thiagoftsm
thiagoftsm previously approved these changes May 26, 2026

@thiagoftsm thiagoftsm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

@Kelpy2004

Copy link
Copy Markdown
Contributor Author

Resolved the conflict by keeping both proc_interrupts_unittest() and test_incremental_sum_lookup_respects_update_every(). The actual proc interrupts fix is unchanged.

@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@stelfrag
stelfrag merged commit 63dc86d into netdata:master May 28, 2026
158 checks passed
@Kelpy2004

Copy link
Copy Markdown
Contributor Author

Thanks for the review.

@Kelpy2004
Kelpy2004 deleted the fix-proc-interrupt-names branch May 29, 2026 07:32
@ilyam8

ilyam8 commented May 29, 2026

Copy link
Copy Markdown
Member

@Kelpy2004, thanks for the fix 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: proc interrupts plugin break the interrupts name

7 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.