From a29d28181b78869a781fb19158a54b5b696ad5f9 Mon Sep 17 00:00:00 2001 From: Kevin Park Date: Fri, 24 Jul 2026 00:27:12 +0900 Subject: [PATCH] sysfs: tolerate EFBIG when reading cpufreq stats/trans_table The kernel refuses to export stats/trans_table when the table exceeds PAGE_SIZE ("cpufreq transition table exceeds PAGE_SIZE. Disabling", drivers/cpufreq/cpufreq_stats.c) and reads then fail with EFBIG. This is common on CPUs with many frequency states, e.g. NVIDIA Jetson (Tegra): SystemCpufreq() fails wholesale, which surfaces in node_exporter as the cpufreq collector failing on every scrape and losing all cpufreq metrics for the node. Treat EFBIG like an absent file, matching the existing ENOENT/EPERM tolerance for this optional stats file. Verified on a Jetson Orin Nano: SystemCpufreq() fails with "file too large" before this change and returns all 6 policy entries after. Signed-off-by: Kevin Park --- sysfs/system_cpu.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sysfs/system_cpu.go b/sysfs/system_cpu.go index 12c5b0bb..64a41eff 100644 --- a/sysfs/system_cpu.go +++ b/sysfs/system_cpu.go @@ -16,11 +16,13 @@ package sysfs import ( + "errors" "fmt" "os" "path/filepath" "strconv" "strings" + "syscall" "golang.org/x/sync/errgroup" @@ -350,10 +352,14 @@ func parseCpufreqCpuinfo(cpuPath string) (*SystemCPUCpufreqStats, error) { } // "trans_table" contains information about all the CPU frequency transitions. + // The kernel disables its export with EFBIG when the table exceeds PAGE_SIZE + // ("cpufreq transition table exceeds PAGE_SIZE. Disabling"), which happens on + // CPUs with many frequency states (e.g. NVIDIA Jetson / Tegra) — treat that + // like an absent file instead of failing the whole cpufreq read. var cpuinfoTransitionTable *[][]uint64 cpuinfoTransitionTableString, err := util.ReadFileNoStat(filepath.Join(cpuPath, "stats", "trans_table")) if err != nil { - if !os.IsNotExist(err) && !os.IsPermission(err) { + if !os.IsNotExist(err) && !os.IsPermission(err) && !errors.Is(err, syscall.EFBIG) { return &SystemCPUCpufreqStats{}, err } } else {