tools/power/turbostat: Relocate thermal probing code
authorZhang Rui <rui.zhang@intel.com>
Thu, 31 Aug 2023 08:02:16 +0000 (16:02 +0800)
committerZhang Rui <rui.zhang@intel.com>
Wed, 27 Sep 2023 14:14:20 +0000 (22:14 +0800)
Introduce probe_thermal(), and move all thermal probing related code
into it.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Len Brown <len.brown@intel.com>
tools/power/x86/turbostat/turbostat.c

index ad9147757d5a506e3a1e0fc3ebd8aaef601e7263..8dae576234a4525378654ff2e222dc4b1e5d5fac 100644 (file)
@@ -4894,6 +4894,14 @@ void probe_rapl(void)
                rapl_probe_amd();
 }
 
+void probe_thermal(void)
+{
+       if (!access("/sys/devices/system/cpu/cpu0/thermal_throttle/core_throttle_count", R_OK))
+               BIC_PRESENT(BIC_CORE_THROT_CNT);
+       else
+               BIC_NOT_PRESENT(BIC_CORE_THROT_CNT);
+}
+
 int print_thermal(struct thread_data *t, struct core_data *c, struct pkg_data *p)
 {
        unsigned long long msr;
@@ -5598,14 +5606,11 @@ void process_cpuid()
 
        probe_rapl();
 
+       probe_thermal();
+
        if (platform->has_nhm_msrs)
                BIC_PRESENT(BIC_SMI);
 
-       if (!access("/sys/devices/system/cpu/cpu0/thermal_throttle/core_throttle_count", R_OK))
-               BIC_PRESENT(BIC_CORE_THROT_CNT);
-       else
-               BIC_NOT_PRESENT(BIC_CORE_THROT_CNT);
-
        if (!quiet)
                decode_misc_feature_control();