diff options
| author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2025-10-15 15:47:45 +0200 |
|---|---|---|
| committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2025-10-20 21:20:49 +0200 |
| commit | c17add73498245bd94cb8a05345c73366606e671 (patch) | |
| tree | 6b585d4867b1eda42a7b4b2c81ca98f68b97a1bc | |
| parent | 528dde6619677ac6dc26d9dda1e3c9014b4a08c8 (diff) | |
cpufreq: intel_pstate: Add and use hybrid_has_l3()
Introduce a function for checking whether or not a given CPU has L3
cache, called hybrid_has_l3(), and use it in hybrid_get_cost() for
computing cost coefficients associated with a given perf domain.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/13884343.uLZWGnKmhe@rafael.j.wysocki
| -rw-r--r-- | drivers/cpufreq/intel_pstate.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 22316c930864..f85056ee6e61 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -951,11 +951,26 @@ static int hybrid_active_power(struct device *dev, unsigned long *power, return 0; } +static bool hybrid_has_l3(unsigned int cpu) +{ + struct cpu_cacheinfo *cacheinfo = get_cpu_cacheinfo(cpu); + unsigned int i; + + if (!cacheinfo) + return false; + + for (i = 0; i < cacheinfo->num_leaves; i++) { + if (cacheinfo->info_list[i].level == 3) + return true; + } + + return false; +} + static int hybrid_get_cost(struct device *dev, unsigned long freq, unsigned long *cost) { struct pstate_data *pstate = &all_cpu_data[dev->id]->pstate; - struct cpu_cacheinfo *cacheinfo = get_cpu_cacheinfo(dev->id); /* * The smaller the perf-to-frequency scaling factor, the larger the IPC @@ -973,17 +988,8 @@ static int hybrid_get_cost(struct device *dev, unsigned long freq, * touching it in case some other CPUs of the same type can do the work * without it. */ - if (cacheinfo) { - unsigned int i; - - /* Check if L3 cache is there. */ - for (i = 0; i < cacheinfo->num_leaves; i++) { - if (cacheinfo->info_list[i].level == 3) { - *cost += 2; - break; - } - } - } + if (hybrid_has_l3(dev->id)) + *cost += 2; return 0; } |
