]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
tools/power turbostat: Handle non-root legacy-uncore sysfs permissions
authorLen Brown <len.brown@intel.com>
Sat, 9 Aug 2025 20:31:31 +0000 (16:31 -0400)
committerLen Brown <len.brown@intel.com>
Sun, 10 Aug 2025 01:24:46 +0000 (21:24 -0400)
/sys/devices/system/cpu/intel_uncore_frequency/package_X_die_Y/
may be readable by all, but
/sys/devices/system/cpu/intel_uncore_frequency/package_X_die_Y/current_freq_khz
may be readable only by root.

Non-root turbostat users see complaints in this scenario.

Fail probe of the interface if we can't read current_freq_khz.

Reported-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Original-patch-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
tools/power/x86/turbostat/turbostat.c

index d65a504a6c5f209560c5e409e03a47b0f6a71f85..76f4093959d519f8263d24fd8c8d8c713ce38187 100644 (file)
@@ -7002,7 +7002,8 @@ static void probe_intel_uncore_frequency_legacy(void)
                        sprintf(path_base, "/sys/devices/system/cpu/intel_uncore_frequency/package_%02d_die_%02d", i,
                                j);
 
-                       if (access(path_base, R_OK))
+                       sprintf(path, "%s/current_freq_khz", path_base);
+                       if (access(path, R_OK))
                                continue;
 
                        BIC_PRESENT(BIC_UNCORE_MHZ);