Repository navigation
sysfs: add NUMANodeCPUList to read per-node CPU lists - #892
Open
baozhuoran wants to merge 3 commits into
Open
baozhuoran wants to merge 3 commits into
baozhuoran wants to merge 3 commits into
Conversation
added 2 commits
October 26, 2026 16:17
Add FS.NUMANodeCPUs, which returns the CPUs of each NUMA node read from /sys/devices/system/node/nodeN/cpulist, keyed by node number. Memory-only nodes return an empty list. The existing parseCPURange helper is reused. Signed-off-by: Zhuoran-Bao <zhuoran.bao@ibm.com>
Name the method after the cpulist file it reads and reference the kernel ABI documentation, per the API implementation guidelines. Signed-off-by: Zhuoran-Bao <zhuoran.bao@ibm.com>
baozhuoran
marked this pull request as ready for review
October 26, 2026 21:32
Signed-off-by: Zhuoran-Bao <zhuoran.bao@ibm.com>
baozhuoran
pushed a commit
to baozhuoran/node_exporter
that referenced
this pull request
Nov 10, 2026
Temporary replace directive pointing at prometheus/procfs#892. Drop this commit and bump github.com/prometheus/procfs once a release contains sysfs.FS.NUMANodeCPUList. Signed-off-by: Zhuoran-Bao <zhuoran.bao@ibm.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
FS.NUMANodeCPUList(), which returns the online CPUs belonging to each NUMA node, read from/sys/devices/system/node/nodeN/cpulist(kernel ABI doc) and keyed by node number. The kernel only lists online CPUs in this file. Memory-only nodes return an empty list.parseCPURangehelper, which already has its own tests.VMStatNUMA.parsers.ReadFileNoStatrather thanSysReadFile, becausecpulistcan exceed 128 bytes on large hosts with non-contiguous CPU numbering.Motivation
node_exporter currently exposes per-NUMA-node memory (
meminfo_numa), but nothing tells you which CPUs belong to which NUMA node. We plan to use this in node_exporter to expose the CPU-to-NUMA-node mapping. That makes it possible to get per-node CPU capacity and to aggregate existing per-CPU metrics by NUMA node. This is useful for NUMA-aware placement, for example checking how much CPU capacity each node has on a hypervisor. Adding the parsing here keeps sysfs parsing out of node_exporter.This PR is a dependency of prometheus/node_exporter#3785, which adds that metric.
Testing
cpulistfixtures fornode1(0-3,8,10-11) andnode2(memory-only, empty).go test ./...,go vet ./...andgolangci-lint(v2.14.0) pass on Linux.