Skip to content

Commit d852b6f

Browse files
committed
cpufreq: intel_pstate: hybrid: Adjust energy model rules
Instead of using HWP-to-frequency scaling factors for computing cost coefficients in the energy model used on hybrid systems, which is fragile, rely on CPU type information that is easily accessible now and the information on whether or not L3 cache is present for this purpose. This also allows the cost coefficients for P-cores to be adjusted so that they start to be populated somewhat earlier (that is, before E-cores are loaded up to their full capacity). In addition to the above, replace an inaccurate comment regarding the reason why the freq value is added to the cost in hybrid_get_cost(). Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Dietmar Eggemann <dietmar.eggemann@arm.com> Reviewed-by: Yaxiong Tian <tianyaxiong@kylinos.cn> Link: https://patch.msgid.link/5932894.DvuYhMxLoT@rafael.j.wysocki
1 parent c17add7 commit d852b6f

1 file changed

Lines changed: 14 additions & 21 deletions

File tree

drivers/cpufreq/intel_pstate.c

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -933,11 +933,8 @@ static int hybrid_active_power(struct device *dev, unsigned long *power,
933933
unsigned long *freq)
934934
{
935935
/*
936-
* Create "utilization bins" of 0-40%, 40%-60%, 60%-80%, and 80%-100%
937-
* of the maximum capacity such that two CPUs of the same type will be
938-
* regarded as equally attractive if the utilization of each of them
939-
* falls into the same bin, which should prevent tasks from being
940-
* migrated between them too often.
936+
* Create four "states" corresponding to 40%, 60%, 80%, and 100% of the
937+
* full capacity.
941938
*
942939
* For this purpose, return the "frequency" of 2 for the first
943940
* performance level and otherwise leave the value set by the caller.
@@ -970,26 +967,22 @@ static bool hybrid_has_l3(unsigned int cpu)
970967
static int hybrid_get_cost(struct device *dev, unsigned long freq,
971968
unsigned long *cost)
972969
{
973-
struct pstate_data *pstate = &all_cpu_data[dev->id]->pstate;
974-
970+
/* Facilitate load balancing between CPUs of the same type. */
971+
*cost = freq;
975972
/*
976-
* The smaller the perf-to-frequency scaling factor, the larger the IPC
977-
* ratio between the given CPU and the least capable CPU in the system.
978-
* Regard that IPC ratio as the primary cost component and assume that
979-
* the scaling factors for different CPU types will differ by at least
980-
* 5% and they will not be above INTEL_PSTATE_CORE_SCALING.
973+
* Adjust the cost depending on CPU type.
981974
*
982-
* Add the freq value to the cost, so that the cost of running on CPUs
983-
* of the same type in different "utilization bins" is different.
984-
*/
985-
*cost = div_u64(100ULL * INTEL_PSTATE_CORE_SCALING, pstate->scaling) + freq;
986-
/*
987-
* Increase the cost slightly for CPUs able to access L3 to avoid
988-
* touching it in case some other CPUs of the same type can do the work
989-
* without it.
975+
* The idea is to start loading up LPE-cores before E-cores and start
976+
* to populate E-cores when LPE-cores are utilized above 60% of the
977+
* capacity. Similarly, P-cores start to be populated when E-cores are
978+
* utilized above 60% of the capacity.
990979
*/
991-
if (hybrid_has_l3(dev->id))
980+
if (hybrid_get_cpu_type(dev->id) == INTEL_CPU_TYPE_ATOM) {
981+
if (hybrid_has_l3(dev->id)) /* E-core */
982+
*cost += 1;
983+
} else { /* P-core */
992984
*cost += 2;
985+
}
993986

994987
return 0;
995988
}

0 commit comments

Comments
 (0)