Skip to content

Commit c17add7

Browse files
committed
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
1 parent 528dde6 commit c17add7

1 file changed

Lines changed: 18 additions & 12 deletions

File tree

drivers/cpufreq/intel_pstate.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -951,11 +951,26 @@ static int hybrid_active_power(struct device *dev, unsigned long *power,
951951
return 0;
952952
}
953953

954+
static bool hybrid_has_l3(unsigned int cpu)
955+
{
956+
struct cpu_cacheinfo *cacheinfo = get_cpu_cacheinfo(cpu);
957+
unsigned int i;
958+
959+
if (!cacheinfo)
960+
return false;
961+
962+
for (i = 0; i < cacheinfo->num_leaves; i++) {
963+
if (cacheinfo->info_list[i].level == 3)
964+
return true;
965+
}
966+
967+
return false;
968+
}
969+
954970
static int hybrid_get_cost(struct device *dev, unsigned long freq,
955971
unsigned long *cost)
956972
{
957973
struct pstate_data *pstate = &all_cpu_data[dev->id]->pstate;
958-
struct cpu_cacheinfo *cacheinfo = get_cpu_cacheinfo(dev->id);
959974

960975
/*
961976
* 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,
973988
* touching it in case some other CPUs of the same type can do the work
974989
* without it.
975990
*/
976-
if (cacheinfo) {
977-
unsigned int i;
978-
979-
/* Check if L3 cache is there. */
980-
for (i = 0; i < cacheinfo->num_leaves; i++) {
981-
if (cacheinfo->info_list[i].level == 3) {
982-
*cost += 2;
983-
break;
984-
}
985-
}
986-
}
991+
if (hybrid_has_l3(dev->id))
992+
*cost += 2;
987993

988994
return 0;
989995
}

0 commit comments

Comments
 (0)