Unlike Cx/Px states, for which we need an extra loop to summerize residency (
sum_cx[]/sum_px[]), we could call get_avgfreq_by_cpuid() right before printing.
Also, with introduction of CPPC mode, average frequency print shall
not depend on the existence of legacy P-states, so we remove "px_cap"
dependancy check.

Fixes: add6160d7 (Add cpufreq actual average freq information to xenpm tools)
Signed-off-by: Penny Zheng <penny.zh...@amd.com>
---
v3 -> v4:
- new commit
---
v4 -> v5:
- refactor title and commit message
- call get_avgfreq_by_cpuid() right before printing
---
 tools/misc/xenpm.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/tools/misc/xenpm.c b/tools/misc/xenpm.c
index f173e598ea..2864506da4 100644
--- a/tools/misc/xenpm.c
+++ b/tools/misc/xenpm.c
@@ -497,9 +497,6 @@ static void signal_int_handler(int signo)
                                  pxstat_start[i].pt[j].residency;
     }
 
-    for ( i = 0; i < max_cpu_nr; i++ )
-        get_avgfreq_by_cpuid(xc_handle, i, &avgfreq[i]);
-
     printf("Elapsed time (ms): %"PRIu64"\n", (usec_end - usec_start) / 1000UL);
     for ( i = 0; i < max_cpu_nr; i++ )
     {
@@ -540,7 +537,8 @@ static void signal_int_handler(int signo)
                         res / 1000000UL, 100UL * res / (double)sum_px[i]);
             }
         }
-        if ( px_cap && avgfreq[i] )
+        get_avgfreq_by_cpuid(xc_handle, i, &avgfreq[i]);
+        if ( avgfreq[i] )
             printf("  Avg freq\t%d\tKHz\n", avgfreq[i]);
     }
 
-- 
2.34.1


Reply via email to