[PATCH v6 03/19] tools: optimize cpufreq average freq print

Penny Zheng posted 19 patches 3 months, 3 weeks ago
Only 18 patches received!
There is a newer version of this series
[PATCH v6 03/19] tools: optimize cpufreq average freq print
Posted by Penny Zheng 3 months, 3 weeks ago
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 later introduction of CPPC mode, average frequency print shall
not depend on the existence of legacy P-states, so we remove "px_cap"
dependancy check.

Signed-off-by: Penny Zheng <Penny.Zheng@amd.com>
---
v3 -> v4:
- new commit
---
v4 -> v5:
- refactor title and commit message
- call get_avgfreq_by_cpuid() right before printing
---
v5 -> v6:
- remove "Fixes:xxx"
---
 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 d5387f5f06..bbe45fa548 100644
--- a/tools/misc/xenpm.c
+++ b/tools/misc/xenpm.c
@@ -510,9 +510,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++ )
     {
@@ -553,7 +550,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
Re: [PATCH v6 03/19] tools: optimize cpufreq average freq print
Posted by Jan Beulich 3 months, 2 weeks ago
On 11.07.2025 05:50, Penny Zheng wrote:
> 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 later introduction of CPPC mode, average frequency print shall
> not depend on the existence of legacy P-states, so we remove "px_cap"
> dependancy check.
> 
> Signed-off-by: Penny Zheng <Penny.Zheng@amd.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>
Re: [PATCH v6 03/19] tools: optimize cpufreq average freq print
Posted by Anthony PERARD 3 months ago
On Wed, Jul 16, 2025 at 04:43:32PM +0200, Jan Beulich wrote:
> On 11.07.2025 05:50, Penny Zheng wrote:
> > 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 later introduction of CPPC mode, average frequency print shall
> > not depend on the existence of legacy P-states, so we remove "px_cap"
> > dependancy check.
> > 
> > Signed-off-by: Penny Zheng <Penny.Zheng@amd.com>
> 
> Reviewed-by: Jan Beulich <jbeulich@suse.com>

Acked-by: Anthony PERARD <anthony.perard@vates.tech>

Thanks,

-- 
Anthony PERARD