Skip to content

procfs: add KernelTainted() to parse /proc/sys/kernel/tainted - #844

Merged
SuperQ merged 4 commits into
prometheus:masterfrom
arunsrini3082:kernel-tainted
Jul 16, 2026
Merged

procfs: add KernelTainted() to parse /proc/sys/kernel/tainted#844
SuperQ merged 4 commits into
prometheus:masterfrom
arunsrini3082:kernel-tainted

Conversation

@arunsrini3082

Copy link
Copy Markdown
Contributor

Add KernelTainted() method on FS that reads /proc/sys/kernel/tainted
and returns the raw taint value along with each known flag parsed into
a KernelTainted struct.

This is required by prometheus/node_exporter to implement a tainted
kernel collector, which was originally proposed in
prometheus/node_exporter#1567 but not merged
because parsing was expected to live in procfs first.

The struct exposes:

  • Value: raw uint64 from /proc/sys/kernel/tainted
  • Bits: slice of KernelTaintBit with Index (bit position), Flag (letter
    code), Description, and Set (whether currently active)

Reference: https://www.kernel.org/doc/html/latest/admin-guide/tainted-kernels.html

@SuperQ

SuperQ commented Jul 15, 2026

Copy link
Copy Markdown
Member

Something is wrong with the testdata change.
image

Signed-off-by: Arun S <arun.srinivasan@flipkart.com>
Comment thread kernel_tainted.go Outdated
Comment thread kernel_tainted.go Outdated
arunsrini3082 and others added 2 commits July 16, 2026 21:47
Co-authored-by: Ben Kochie <superq@gmail.com>
Signed-off-by: Arun Srinivasan <arunpiter@gmail.com>
Co-authored-by: Ben Kochie <superq@gmail.com>
Signed-off-by: Arun Srinivasan <arunpiter@gmail.com>
@arunsrini3082
arunsrini3082 requested a review from SuperQ July 16, 2026 16:18
Signed-off-by: Arun S <arun.srinivasan@flipkart.com>
@arunsrini3082

Copy link
Copy Markdown
Contributor Author

@SuperQ Thanks for the suggestions! I've applied both and reconciled them — since SysReadUintFromFile already returns uint64, I updated parseTainted to accept uint64 directly (no more io.Reader or string parsing). The "io", "fmt", "strconv", and "strings" imports are now removed, and the test updated accordingly. Pushed in the latest commit.

@SuperQ
SuperQ merged commit 1de9cf3 into prometheus:master Jul 16, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants