[PATCH v3 06/15] xen/cpufreq: disable px statistic info in amd-cppc mode

Penny Zheng posted 15 patches 11 months, 1 week ago
There is a newer version of this series
[PATCH v3 06/15] xen/cpufreq: disable px statistic info in amd-cppc mode
Posted by Penny Zheng 11 months, 1 week ago
Bypass cnstruction and deconstruction for px statistic info(
cpufreq_statistic_init and cpufreq_statistic_exit) in cpufreq
CPPC mode.

Signed-off-by: Penny Zheng <Penny.Zheng@amd.com>
---
v2 -> v3:
- new commit
---
 xen/drivers/cpufreq/utility.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/xen/drivers/cpufreq/utility.c b/xen/drivers/cpufreq/utility.c
index e690a484f1..f1fd2fdbce 100644
--- a/xen/drivers/cpufreq/utility.c
+++ b/xen/drivers/cpufreq/utility.c
@@ -98,6 +98,9 @@ int cpufreq_statistic_init(unsigned int cpu)
     if ( !pmpt )
         return -EINVAL;
 
+    if ( !(pmpt->init & XEN_PX_INIT) )
+        return 0;
+
     spin_lock(cpufreq_statistic_lock);
 
     pxpt = per_cpu(cpufreq_statistic_data, cpu);
@@ -147,8 +150,12 @@ int cpufreq_statistic_init(unsigned int cpu)
 void cpufreq_statistic_exit(unsigned int cpu)
 {
     struct pm_px *pxpt;
+    const struct processor_pminfo *pmpt = processor_pminfo[cpu];
     spinlock_t *cpufreq_statistic_lock = &per_cpu(cpufreq_statistic_lock, cpu);
 
+    if ( !(pmpt->init & XEN_PX_INIT) )
+        return;
+
     spin_lock(cpufreq_statistic_lock);
 
     pxpt = per_cpu(cpufreq_statistic_data, cpu);
-- 
2.34.1
Re: [PATCH v3 06/15] xen/cpufreq: disable px statistic info in amd-cppc mode
Posted by Jan Beulich 10 months, 3 weeks ago
On 06.03.2025 09:39, Penny Zheng wrote:
> Bypass cnstruction and deconstruction for px statistic info(
> cpufreq_statistic_init and cpufreq_statistic_exit) in cpufreq
> CPPC mode.

You say what you do, but not why.

> --- a/xen/drivers/cpufreq/utility.c
> +++ b/xen/drivers/cpufreq/utility.c
> @@ -98,6 +98,9 @@ int cpufreq_statistic_init(unsigned int cpu)
>      if ( !pmpt )
>          return -EINVAL;
>  
> +    if ( !(pmpt->init & XEN_PX_INIT) )
> +        return 0;

I understand this is needed if statistics really are of no interest for this
driver (which needs to be clarified in the description). However, ...

> @@ -147,8 +150,12 @@ int cpufreq_statistic_init(unsigned int cpu)
>  void cpufreq_statistic_exit(unsigned int cpu)
>  {
>      struct pm_px *pxpt;
> +    const struct processor_pminfo *pmpt = processor_pminfo[cpu];
>      spinlock_t *cpufreq_statistic_lock = &per_cpu(cpufreq_statistic_lock, cpu);
>  
> +    if ( !(pmpt->init & XEN_PX_INIT) )
> +        return;
> +
>      spin_lock(cpufreq_statistic_lock);
>  
>      pxpt = per_cpu(cpufreq_statistic_data, cpu);

... why's this needed, when below here there already is:

    if (!pxpt) {
        spin_unlock(cpufreq_statistic_lock);
        return;
    }

?

Jan