Message ID | 8476313.T7Z3S40VBb@rjwysocki.net |
---|---|
State | New |
Headers | show |
Series | intel_pstate: Use information from CPPC to compute hybrid scaling factors | expand |
On 5/1/25 12:13 PM, srinivas pandruvada wrote: > Hi Russell, > > > On Wed, 2025-04-30 at 20:28 -0500, Russell Haley wrote: >> >> On 12/5/24 5:39 AM, Rafael J. Wysocki wrote: >> >>> + * Compute the perf-to-frequency scaling factor for the >>> given CPU if >>> + * possible, unless it would be 0. >>> + */ >>> + if (!cppc_get_perf_caps(cpu, &cppc_perf) && >>> + cppc_perf.nominal_perf && cppc_perf.nominal_freq) >>> + return div_u64(cppc_perf.nominal_freq * >>> KHZ_PER_MHZ, >>> + cppc_perf.nominal_perf); >> > Can you dump the output of > > grep -r . /sys/devices/system/cpu/cpu*/acpi_cppc/ > > Thanks, > Srinivas Running microcode 0x117, CSME firmware 19.0.5.1948, shipped in BIOS 3.04 on an ASRock Z890 Pro-A Wifi motherboard: > /sys/devices/system/cpu/cpu0/acpi_cppc/feedback_ctrs:ref:127316207577 del:142876300546 > /sys/devices/system/cpu/cpu0/acpi_cppc/lowest_nonlinear_perf:36 > /sys/devices/system/cpu/cpu0/acpi_cppc/highest_perf:87 > /sys/devices/system/cpu/cpu0/acpi_cppc/nominal_freq:3900 > /sys/devices/system/cpu/cpu0/acpi_cppc/lowest_freq:0 > /sys/devices/system/cpu/cpu0/acpi_cppc/guaranteed_perf:63 > /sys/devices/system/cpu/cpu0/acpi_cppc/nominal_perf:62 > /sys/devices/system/cpu/cpu0/acpi_cppc/lowest_perf:1 > /sys/devices/system/cpu/cpu0/acpi_cppc/reference_perf:62 > /sys/devices/system/cpu/cpu0/acpi_cppc/wraparound_time:18446744073709551615 > /sys/devices/system/cpu/cpu1/acpi_cppc/feedback_ctrs:ref:30806048910 del:37298826546 > /sys/devices/system/cpu/cpu1/acpi_cppc/lowest_nonlinear_perf:36 > /sys/devices/system/cpu/cpu1/acpi_cppc/highest_perf:88 > /sys/devices/system/cpu/cpu1/acpi_cppc/nominal_freq:3900 > /sys/devices/system/cpu/cpu1/acpi_cppc/lowest_freq:0 > /sys/devices/system/cpu/cpu1/acpi_cppc/guaranteed_perf:63 > /sys/devices/system/cpu/cpu1/acpi_cppc/nominal_perf:62 > /sys/devices/system/cpu/cpu1/acpi_cppc/lowest_perf:1 > /sys/devices/system/cpu/cpu1/acpi_cppc/reference_perf:62 > /sys/devices/system/cpu/cpu1/acpi_cppc/wraparound_time:18446744073709551615 > /sys/devices/system/cpu/cpu2/acpi_cppc/feedback_ctrs:ref:30104856912 del:37149315858 > /sys/devices/system/cpu/cpu2/acpi_cppc/lowest_nonlinear_perf:36 > /sys/devices/system/cpu/cpu2/acpi_cppc/highest_perf:87 > /sys/devices/system/cpu/cpu2/acpi_cppc/nominal_freq:3900 > /sys/devices/system/cpu/cpu2/acpi_cppc/lowest_freq:0 > /sys/devices/system/cpu/cpu2/acpi_cppc/guaranteed_perf:63 > /sys/devices/system/cpu/cpu2/acpi_cppc/nominal_perf:62 > /sys/devices/system/cpu/cpu2/acpi_cppc/lowest_perf:1 > /sys/devices/system/cpu/cpu2/acpi_cppc/reference_perf:62 > /sys/devices/system/cpu/cpu2/acpi_cppc/wraparound_time:18446744073709551615 > /sys/devices/system/cpu/cpu3/acpi_cppc/feedback_ctrs:ref:28864792476 del:36395338959 > /sys/devices/system/cpu/cpu3/acpi_cppc/lowest_nonlinear_perf:36 > /sys/devices/system/cpu/cpu3/acpi_cppc/highest_perf:87 > /sys/devices/system/cpu/cpu3/acpi_cppc/nominal_freq:3900 > /sys/devices/system/cpu/cpu3/acpi_cppc/lowest_freq:0 > /sys/devices/system/cpu/cpu3/acpi_cppc/guaranteed_perf:63 > /sys/devices/system/cpu/cpu3/acpi_cppc/nominal_perf:62 > /sys/devices/system/cpu/cpu3/acpi_cppc/lowest_perf:1 > /sys/devices/system/cpu/cpu3/acpi_cppc/reference_perf:62 > /sys/devices/system/cpu/cpu3/acpi_cppc/wraparound_time:18446744073709551615 > /sys/devices/system/cpu/cpu4/acpi_cppc/feedback_ctrs:ref:29591299374 del:35708084379 > /sys/devices/system/cpu/cpu4/acpi_cppc/lowest_nonlinear_perf:36 > /sys/devices/system/cpu/cpu4/acpi_cppc/highest_perf:87 > /sys/devices/system/cpu/cpu4/acpi_cppc/nominal_freq:3900 > /sys/devices/system/cpu/cpu4/acpi_cppc/lowest_freq:0 > /sys/devices/system/cpu/cpu4/acpi_cppc/guaranteed_perf:63 > /sys/devices/system/cpu/cpu4/acpi_cppc/nominal_perf:62 > /sys/devices/system/cpu/cpu4/acpi_cppc/lowest_perf:1 > /sys/devices/system/cpu/cpu4/acpi_cppc/reference_perf:62 > /sys/devices/system/cpu/cpu4/acpi_cppc/wraparound_time:18446744073709551615 > /sys/devices/system/cpu/cpu5/acpi_cppc/feedback_ctrs:ref:27347351382 del:35000915045 > /sys/devices/system/cpu/cpu5/acpi_cppc/lowest_nonlinear_perf:36 > /sys/devices/system/cpu/cpu5/acpi_cppc/highest_perf:87 > /sys/devices/system/cpu/cpu5/acpi_cppc/nominal_freq:3900 > /sys/devices/system/cpu/cpu5/acpi_cppc/lowest_freq:0 > /sys/devices/system/cpu/cpu5/acpi_cppc/guaranteed_perf:63 > /sys/devices/system/cpu/cpu5/acpi_cppc/nominal_perf:62 > /sys/devices/system/cpu/cpu5/acpi_cppc/lowest_perf:1 > /sys/devices/system/cpu/cpu5/acpi_cppc/reference_perf:62 > /sys/devices/system/cpu/cpu5/acpi_cppc/wraparound_time:18446744073709551615 > /sys/devices/system/cpu/cpu6/acpi_cppc/feedback_ctrs:ref:28117737882 del:34854014824 > /sys/devices/system/cpu/cpu6/acpi_cppc/lowest_nonlinear_perf:36 > /sys/devices/system/cpu/cpu6/acpi_cppc/highest_perf:87 > /sys/devices/system/cpu/cpu6/acpi_cppc/nominal_freq:3900 > /sys/devices/system/cpu/cpu6/acpi_cppc/lowest_freq:0 > /sys/devices/system/cpu/cpu6/acpi_cppc/guaranteed_perf:63 > /sys/devices/system/cpu/cpu6/acpi_cppc/nominal_perf:62 > /sys/devices/system/cpu/cpu6/acpi_cppc/lowest_perf:1 > /sys/devices/system/cpu/cpu6/acpi_cppc/reference_perf:62 > /sys/devices/system/cpu/cpu6/acpi_cppc/wraparound_time:18446744073709551615 > /sys/devices/system/cpu/cpu7/acpi_cppc/feedback_ctrs:ref:29586359166 del:36871078184 > /sys/devices/system/cpu/cpu7/acpi_cppc/lowest_nonlinear_perf:36 > /sys/devices/system/cpu/cpu7/acpi_cppc/highest_perf:88 > /sys/devices/system/cpu/cpu7/acpi_cppc/nominal_freq:3900 > /sys/devices/system/cpu/cpu7/acpi_cppc/lowest_freq:0 > /sys/devices/system/cpu/cpu7/acpi_cppc/guaranteed_perf:63 > /sys/devices/system/cpu/cpu7/acpi_cppc/nominal_perf:62 > /sys/devices/system/cpu/cpu7/acpi_cppc/lowest_perf:1 > /sys/devices/system/cpu/cpu7/acpi_cppc/reference_perf:62 > /sys/devices/system/cpu/cpu7/acpi_cppc/wraparound_time:18446744073709551615 > /sys/devices/system/cpu/cpu8/acpi_cppc/feedback_ctrs:ref:28808115336 del:32798153181 > /sys/devices/system/cpu/cpu8/acpi_cppc/lowest_nonlinear_perf:21 > /sys/devices/system/cpu/cpu8/acpi_cppc/highest_perf:65 > /sys/devices/system/cpu/cpu8/acpi_cppc/nominal_freq:3300 > /sys/devices/system/cpu/cpu8/acpi_cppc/lowest_freq:0 > /sys/devices/system/cpu/cpu8/acpi_cppc/guaranteed_perf:47 > /sys/devices/system/cpu/cpu8/acpi_cppc/nominal_perf:46 > /sys/devices/system/cpu/cpu8/acpi_cppc/lowest_perf:1 > /sys/devices/system/cpu/cpu8/acpi_cppc/reference_perf:54 > /sys/devices/system/cpu/cpu8/acpi_cppc/wraparound_time:18446744073709551615 > /sys/devices/system/cpu/cpu9/acpi_cppc/feedback_ctrs:ref:28808446524 del:32557156736 > /sys/devices/system/cpu/cpu9/acpi_cppc/lowest_nonlinear_perf:21 > /sys/devices/system/cpu/cpu9/acpi_cppc/highest_perf:65 > /sys/devices/system/cpu/cpu9/acpi_cppc/nominal_freq:3300 > /sys/devices/system/cpu/cpu9/acpi_cppc/lowest_freq:0 > /sys/devices/system/cpu/cpu9/acpi_cppc/guaranteed_perf:47 > /sys/devices/system/cpu/cpu9/acpi_cppc/nominal_perf:46 > /sys/devices/system/cpu/cpu9/acpi_cppc/lowest_perf:1 > /sys/devices/system/cpu/cpu9/acpi_cppc/reference_perf:54 > /sys/devices/system/cpu/cpu9/acpi_cppc/wraparound_time:18446744073709551615 > /sys/devices/system/cpu/cpu10/acpi_cppc/feedback_ctrs:ref:28466858472 del:32126528930 > /sys/devices/system/cpu/cpu10/acpi_cppc/lowest_nonlinear_perf:21 > /sys/devices/system/cpu/cpu10/acpi_cppc/highest_perf:65 > /sys/devices/system/cpu/cpu10/acpi_cppc/nominal_freq:3300 > /sys/devices/system/cpu/cpu10/acpi_cppc/lowest_freq:0 > /sys/devices/system/cpu/cpu10/acpi_cppc/guaranteed_perf:47 > /sys/devices/system/cpu/cpu10/acpi_cppc/nominal_perf:46 > /sys/devices/system/cpu/cpu10/acpi_cppc/lowest_perf:1 > /sys/devices/system/cpu/cpu10/acpi_cppc/reference_perf:54 > /sys/devices/system/cpu/cpu10/acpi_cppc/wraparound_time:18446744073709551615 > /sys/devices/system/cpu/cpu11/acpi_cppc/feedback_ctrs:ref:30158667240 del:34095663687 > /sys/devices/system/cpu/cpu11/acpi_cppc/lowest_nonlinear_perf:21 > /sys/devices/system/cpu/cpu11/acpi_cppc/highest_perf:65 > /sys/devices/system/cpu/cpu11/acpi_cppc/nominal_freq:3300 > /sys/devices/system/cpu/cpu11/acpi_cppc/lowest_freq:0 > /sys/devices/system/cpu/cpu11/acpi_cppc/guaranteed_perf:47 > /sys/devices/system/cpu/cpu11/acpi_cppc/nominal_perf:46 > /sys/devices/system/cpu/cpu11/acpi_cppc/lowest_perf:1 > /sys/devices/system/cpu/cpu11/acpi_cppc/reference_perf:54 > /sys/devices/system/cpu/cpu11/acpi_cppc/wraparound_time:18446744073709551615 > /sys/devices/system/cpu/cpu12/acpi_cppc/feedback_ctrs:ref:29056752036 del:33047611525 > /sys/devices/system/cpu/cpu12/acpi_cppc/lowest_nonlinear_perf:21 > /sys/devices/system/cpu/cpu12/acpi_cppc/highest_perf:65 > /sys/devices/system/cpu/cpu12/acpi_cppc/nominal_freq:3300 > /sys/devices/system/cpu/cpu12/acpi_cppc/lowest_freq:0 > /sys/devices/system/cpu/cpu12/acpi_cppc/guaranteed_perf:47 > /sys/devices/system/cpu/cpu12/acpi_cppc/nominal_perf:33 > /sys/devices/system/cpu/cpu12/acpi_cppc/lowest_perf:1 > /sys/devices/system/cpu/cpu12/acpi_cppc/reference_perf:39 > /sys/devices/system/cpu/cpu12/acpi_cppc/wraparound_time:18446744073709551615 > /sys/devices/system/cpu/cpu13/acpi_cppc/feedback_ctrs:ref:28868999796 del:32974873909 > /sys/devices/system/cpu/cpu13/acpi_cppc/lowest_nonlinear_perf:21 > /sys/devices/system/cpu/cpu13/acpi_cppc/highest_perf:65 > /sys/devices/system/cpu/cpu13/acpi_cppc/nominal_freq:3300 > /sys/devices/system/cpu/cpu13/acpi_cppc/lowest_freq:0 > /sys/devices/system/cpu/cpu13/acpi_cppc/guaranteed_perf:47 > /sys/devices/system/cpu/cpu13/acpi_cppc/nominal_perf:33 > /sys/devices/system/cpu/cpu13/acpi_cppc/lowest_perf:1 > /sys/devices/system/cpu/cpu13/acpi_cppc/reference_perf:39 > /sys/devices/system/cpu/cpu13/acpi_cppc/wraparound_time:18446744073709551615 > /sys/devices/system/cpu/cpu14/acpi_cppc/feedback_ctrs:ref:32754342192 del:33580705618 > /sys/devices/system/cpu/cpu14/acpi_cppc/lowest_nonlinear_perf:21 > /sys/devices/system/cpu/cpu14/acpi_cppc/highest_perf:65 > /sys/devices/system/cpu/cpu14/acpi_cppc/nominal_freq:3300 > /sys/devices/system/cpu/cpu14/acpi_cppc/lowest_freq:0 > /sys/devices/system/cpu/cpu14/acpi_cppc/guaranteed_perf:47 > /sys/devices/system/cpu/cpu14/acpi_cppc/nominal_perf:46 > /sys/devices/system/cpu/cpu14/acpi_cppc/lowest_perf:1 > /sys/devices/system/cpu/cpu14/acpi_cppc/reference_perf:54 > /sys/devices/system/cpu/cpu14/acpi_cppc/wraparound_time:18446744073709551615 > /sys/devices/system/cpu/cpu15/acpi_cppc/feedback_ctrs:ref:30756411036 del:33232643243 > /sys/devices/system/cpu/cpu15/acpi_cppc/lowest_nonlinear_perf:21 > /sys/devices/system/cpu/cpu15/acpi_cppc/highest_perf:65 > /sys/devices/system/cpu/cpu15/acpi_cppc/nominal_freq:3300 > /sys/devices/system/cpu/cpu15/acpi_cppc/lowest_freq:0 > /sys/devices/system/cpu/cpu15/acpi_cppc/guaranteed_perf:47 > /sys/devices/system/cpu/cpu15/acpi_cppc/nominal_perf:46 > /sys/devices/system/cpu/cpu15/acpi_cppc/lowest_perf:1 > /sys/devices/system/cpu/cpu15/acpi_cppc/reference_perf:54 > /sys/devices/system/cpu/cpu15/acpi_cppc/wraparound_time:18446744073709551615 > /sys/devices/system/cpu/cpu16/acpi_cppc/feedback_ctrs:ref:29430330384 del:32848376143 > /sys/devices/system/cpu/cpu16/acpi_cppc/lowest_nonlinear_perf:21 > /sys/devices/system/cpu/cpu16/acpi_cppc/highest_perf:65 > /sys/devices/system/cpu/cpu16/acpi_cppc/nominal_freq:3300 > /sys/devices/system/cpu/cpu16/acpi_cppc/lowest_freq:0 > /sys/devices/system/cpu/cpu16/acpi_cppc/guaranteed_perf:47 > /sys/devices/system/cpu/cpu16/acpi_cppc/nominal_perf:46 > /sys/devices/system/cpu/cpu16/acpi_cppc/lowest_perf:1 > /sys/devices/system/cpu/cpu16/acpi_cppc/reference_perf:54 > /sys/devices/system/cpu/cpu16/acpi_cppc/wraparound_time:18446744073709551615 > /sys/devices/system/cpu/cpu17/acpi_cppc/feedback_ctrs:ref:29997814080 del:33374419073 > /sys/devices/system/cpu/cpu17/acpi_cppc/lowest_nonlinear_perf:21 > /sys/devices/system/cpu/cpu17/acpi_cppc/highest_perf:65 > /sys/devices/system/cpu/cpu17/acpi_cppc/nominal_freq:3300 > /sys/devices/system/cpu/cpu17/acpi_cppc/lowest_freq:0 > /sys/devices/system/cpu/cpu17/acpi_cppc/guaranteed_perf:47 > /sys/devices/system/cpu/cpu17/acpi_cppc/nominal_perf:46 > /sys/devices/system/cpu/cpu17/acpi_cppc/lowest_perf:1 > /sys/devices/system/cpu/cpu17/acpi_cppc/reference_perf:54 > /sys/devices/system/cpu/cpu17/acpi_cppc/wraparound_time:18446744073709551615 > /sys/devices/system/cpu/cpu18/acpi_cppc/feedback_ctrs:ref:28312400376 del:32285787922 > /sys/devices/system/cpu/cpu18/acpi_cppc/lowest_nonlinear_perf:21 > /sys/devices/system/cpu/cpu18/acpi_cppc/highest_perf:65 > /sys/devices/system/cpu/cpu18/acpi_cppc/nominal_freq:3300 > /sys/devices/system/cpu/cpu18/acpi_cppc/lowest_freq:0 > /sys/devices/system/cpu/cpu18/acpi_cppc/guaranteed_perf:47 > /sys/devices/system/cpu/cpu18/acpi_cppc/nominal_perf:46 > /sys/devices/system/cpu/cpu18/acpi_cppc/lowest_perf:1 > /sys/devices/system/cpu/cpu18/acpi_cppc/reference_perf:54 > /sys/devices/system/cpu/cpu18/acpi_cppc/wraparound_time:18446744073709551615 > /sys/devices/system/cpu/cpu19/acpi_cppc/feedback_ctrs:ref:28316604732 del:32229146887 > /sys/devices/system/cpu/cpu19/acpi_cppc/lowest_nonlinear_perf:21 > /sys/devices/system/cpu/cpu19/acpi_cppc/highest_perf:65 > /sys/devices/system/cpu/cpu19/acpi_cppc/nominal_freq:3300 > /sys/devices/system/cpu/cpu19/acpi_cppc/lowest_freq:0 > /sys/devices/system/cpu/cpu19/acpi_cppc/guaranteed_perf:47 > /sys/devices/system/cpu/cpu19/acpi_cppc/nominal_perf:46 > /sys/devices/system/cpu/cpu19/acpi_cppc/lowest_perf:1 > /sys/devices/system/cpu/cpu19/acpi_cppc/reference_perf:54 > /sys/devices/system/cpu/cpu19/acpi_cppc/wraparound_time:18446744073709551615 Thanks, Russell
Index: linux-pm/drivers/cpufreq/intel_pstate.c =================================================================== --- linux-pm.orig/drivers/cpufreq/intel_pstate.c +++ linux-pm/drivers/cpufreq/intel_pstate.c @@ -28,6 +28,7 @@ #include <linux/pm_qos.h> #include <linux/bitfield.h> #include <trace/events/power.h> +#include <linux/units.h> #include <asm/cpu.h> #include <asm/div64.h> @@ -302,11 +303,11 @@ static bool hwp_is_hybrid; static struct cpufreq_driver *intel_pstate_driver __read_mostly; -#define HYBRID_SCALING_FACTOR 78741 +#define HYBRID_SCALING_FACTOR_ADL 78741 #define HYBRID_SCALING_FACTOR_MTL 80000 #define HYBRID_SCALING_FACTOR_LNL 86957 -static int hybrid_scaling_factor = HYBRID_SCALING_FACTOR; +static int hybrid_scaling_factor; static inline int core_get_scaling(void) { @@ -414,18 +415,15 @@ static int intel_pstate_get_cppc_guarant static int intel_pstate_cppc_get_scaling(int cpu) { struct cppc_perf_caps cppc_perf; - int ret; - - ret = cppc_get_perf_caps(cpu, &cppc_perf); /* - * If the nominal frequency and the nominal performance are not - * zero and the ratio between them is not 100, return the hybrid - * scaling factor. - */ - if (!ret && cppc_perf.nominal_perf && cppc_perf.nominal_freq && - cppc_perf.nominal_perf * 100 != cppc_perf.nominal_freq) - return hybrid_scaling_factor; + * Compute the perf-to-frequency scaling factor for the given CPU if + * possible, unless it would be 0. + */ + if (!cppc_get_perf_caps(cpu, &cppc_perf) && + cppc_perf.nominal_perf && cppc_perf.nominal_freq) + return div_u64(cppc_perf.nominal_freq * KHZ_PER_MHZ, + cppc_perf.nominal_perf); return core_get_scaling(); } @@ -2211,24 +2209,30 @@ static void hybrid_get_type(void *data) static int hwp_get_cpu_scaling(int cpu) { - u8 cpu_type = 0; + if (hybrid_scaling_factor) { + u8 cpu_type = 0; + + smp_call_function_single(cpu, hybrid_get_type, &cpu_type, 1); - smp_call_function_single(cpu, hybrid_get_type, &cpu_type, 1); - /* P-cores have a smaller perf level-to-freqency scaling factor. */ - if (cpu_type == 0x40) - return hybrid_scaling_factor; + /* + * Return the hybrid scaling factor for P-cores and use the + * default core scaling for E-cores. + */ + if (cpu_type == 0x40) + return hybrid_scaling_factor; - /* Use default core scaling for E-cores */ - if (cpu_type == 0x20) + if (cpu_type == 0x20) + return core_get_scaling(); + } + + /* Use core scaling on non-hybrid systems. */ + if (!cpu_feature_enabled(X86_FEATURE_HYBRID_CPU)) return core_get_scaling(); /* - * If reached here, this system is either non-hybrid (like Tiger - * Lake) or hybrid-capable (like Alder Lake or Raptor Lake) with - * no E cores (in which case CPUID for hybrid support is 0). - * - * The CPPC nominal_frequency field is 0 for non-hybrid systems, - * so the default core scaling will be used for them. + * The system is hybrid, but the hybrid scaling factor is not known or + * the CPU type is not one of the above, so use CPPC to compute the + * scaling factor for this CPU. */ return intel_pstate_cppc_get_scaling(cpu); } @@ -3665,6 +3669,11 @@ static const struct x86_cpu_id intel_epp }; static const struct x86_cpu_id intel_hybrid_scaling_factor[] = { + X86_MATCH_VFM(INTEL_ALDERLAKE, HYBRID_SCALING_FACTOR_ADL), + X86_MATCH_VFM(INTEL_ALDERLAKE_L, HYBRID_SCALING_FACTOR_ADL), + X86_MATCH_VFM(INTEL_RAPTORLAKE, HYBRID_SCALING_FACTOR_ADL), + X86_MATCH_VFM(INTEL_RAPTORLAKE_P, HYBRID_SCALING_FACTOR_ADL), + X86_MATCH_VFM(INTEL_RAPTORLAKE_S, HYBRID_SCALING_FACTOR_ADL), X86_MATCH_VFM(INTEL_METEORLAKE_L, HYBRID_SCALING_FACTOR_MTL), X86_MATCH_VFM(INTEL_ARROWLAKE, HYBRID_SCALING_FACTOR_MTL), X86_MATCH_VFM(INTEL_LUNARLAKE_M, HYBRID_SCALING_FACTOR_LNL),