tools/power/turbostat: Relocate pstate probing code
authorZhang Rui <rui.zhang@intel.com>
Thu, 31 Aug 2023 07:58:10 +0000 (15:58 +0800)
committerZhang Rui <rui.zhang@intel.com>
Wed, 27 Sep 2023 14:14:20 +0000 (22:14 +0800)
Introduce probe_pstates() and move all pstate 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 e5ca1586961e7a024bfc23a95d6249718732f404..1bcaee6d0eadf210e1f59db7c4c12c8c05c6f6a3 100644 (file)
@@ -3016,6 +3016,9 @@ static void dump_platform_info(void)
        unsigned long long msr;
        unsigned int ratio;
 
+       if (!platform->has_nhm_msrs)
+               return;
+
        get_msr(base_cpu, MSR_PLATFORM_INFO, &msr);
 
        fprintf(outf, "cpu%d: MSR_PLATFORM_INFO: 0x%08llx\n", base_cpu, msr);
@@ -4313,6 +4316,9 @@ static void dump_turbo_ratio_info(void)
        if (!has_turbo)
                return;
 
+       if (!platform->has_nhm_msrs)
+               return;
+
        if (platform->trl_msrs & TRL_LIMIT2)
                dump_turbo_ratio_limit2();
 
@@ -4336,15 +4342,6 @@ static void dump_turbo_ratio_info(void)
                dump_config_tdp();
 }
 
-static void dump_cstate_pstate_config_info(void)
-{
-       if (!platform->has_nhm_msrs)
-               return;
-
-       dump_platform_info();
-       dump_turbo_ratio_info();
-}
-
 static int read_sysfs_int(char *path)
 {
        FILE *input;
@@ -5363,6 +5360,19 @@ void probe_cstates(void)
        dump_sysfs_cstate_config();
 }
 
+void probe_pstates(void)
+{
+       probe_bclk();
+
+       if (quiet)
+               return;
+
+       dump_platform_info();
+       dump_turbo_ratio_info();
+       dump_sysfs_pstate_config();
+       decode_misc_pwr_mgmt_msr();
+}
+
 void process_cpuid()
 {
        unsigned int eax, ebx, ecx, edx;
@@ -5542,24 +5552,17 @@ void process_cpuid()
        BIC_PRESENT(BIC_IRQ);
        BIC_PRESENT(BIC_TSC_MHz);
 
+       probe_pstates();
+
        probe_cstates();
 
        if (platform->has_nhm_msrs)
                BIC_PRESENT(BIC_SMI);
-       probe_bclk();
-
-       if (!quiet)
-               decode_misc_pwr_mgmt_msr();
 
        rapl_probe();
 
-       if (!quiet)
-               dump_cstate_pstate_config_info();
        intel_uncore_frequency_probe();
 
-       if (!quiet)
-               dump_sysfs_pstate_config();
-
        if (!access("/sys/class/drm/card0/power/rc6_residency_ms", R_OK))
                BIC_PRESENT(BIC_GFX_rc6);