Skip to contentSkip to conversation

x86/pmstat: drop struct px_stat's usable field

PATCH In review Jan Beulich 2 participants 2 messages Jul 23, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/pmstat: drop struct px_stat's usable field

Its initial calculation in cpufreq_statistic_init() is entirely unused, as do_get_pm_info() recalculates it before use. That re-calculation can then be done right where the output field is set, eliminating the need for the internal field. In turn the struct pointer there can then be constified.

xen/drivers/acpi/pmstat.c +2 -5
@@ -144,7 +144,6 @@ int cpufreq_statistic_init(unsigned int
     }
 
     pxpt->u.total = count;
-    pxpt->u.usable = count - pmpt->perf.platform_limit;
 
     for ( i = 0; i < count; i++ )
         pxpt->u.pt[i].freq = pmpt->perf.states[i].core_frequency;
@@ -257,7 +256,7 @@ int do_get_pm_info(struct xen_sysctl_get
     case PMSTAT_get_pxstat:
     {
         uint32_t ct;
-        struct pm_px *pxpt;
+        const struct pm_px *pxpt;
         spinlock_t *cpufreq_statistic_lock = 
                    &per_cpu(cpufreq_statistic_lock, op->cpuid);
 
@@ -270,8 +269,6 @@ int do_get_pm_info(struct xen_sysctl_get
             return -ENODATA;
         }
 
-        pxpt->u.usable = pmpt->perf.state_count - pmpt->perf.platform_limit;
-
         cpufreq_residency_update(op->cpuid, pxpt->u.cur);
 
         /*
@@ -296,7 +293,7 @@ int do_get_pm_info(struct xen_sysctl_get
         }
 
         op->u.getpx.total = pxpt->u.total;
-        op->u.getpx.usable = pxpt->u.usable;
+        op->u.getpx.usable = pmpt->perf.state_count - pmpt->perf.platform_limit;
         op->u.getpx.last = pxpt->u.last;
         op->u.getpx.cur = pxpt->u.cur;
 
xen/include/acpi/cpufreq/processor_perf.h +0 -1
@@ -51,7 +51,6 @@ extern struct processor_pminfo *processo
 
 struct px_stat {
     uint8_t total;        /* total Px states */
-    uint8_t usable;       /* usable Px states */
     uint8_t last;         /* last Px state */
     uint8_t cur;          /* current Px state */
     uint64_t *trans_pt;   /* Px transition table */
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Jan Beulich

Its initial calculation in cpufreq_statistic_init() is entirely unused, as do_get_pm_info() recalculates it before use. That re-calculation can then be done right where the output field is set, eliminating the need for the internal field. In turn the struct pointer there can then be constified.