Skip to contentSkip to conversation

tools/power/x86/intel-speed-select: Fixes for regression

PATCH New Srinivas Pandruvada 2 participants 7 messages Dec 21, 2020 – Jan 4, 2021

Subsystems (2)
lore
Share & tools
lore

Srinivas Pandruvada

author maintainer
#0 lore raw

One side-effect of fixing the scaling frequency limits using the commit eacc9c5a927e ("cpufreq: intel_pstate: Fix intel_pstate_get_hwp_max() for turbo disabled") causes stale HWP_CAP.GUARANTEED to be used as max. Without processing HWP interrupts, user space needs to be able to update a new max while Intel SST is in use. This is not a problem as the change of guaranteed is caused by user space action, so user space knows that guarantee will change.

This series causes user space to trigger scaling_max_freq update with the new base_frequency.

Srinivas Pandruvada (2):
tools/power/x86/intel-speed-select: Set scaling_max_freq to
base_frequency
tools/power/x86/intel-speed-select: Set higher of cpuinfo_max_freq or
base_frequency

 .../x86/intel-speed-select/isst-config.c      | 32 +++++++++++++++++++
 1 file changed, 32 insertions(+)
Signature · 1 line
2.29.2
author maintainer
#1 lore raw

PATCH 1/2 tools/power/x86/intel-speed-select: Set scaling_max_freq to base_frequency

When BIOS disables turbo, The scaling_max_freq in cpufreq sysfs will be limited to config level 0 base frequency. But when user selects a higher config levels, this will result in higher base frequency. But since scaling_max_freq is still old base frequency, the performance will still be limited. So when the turbo is disabled and cpufreq base_frequency is higher than scaling_max_freq, update the scaling_max_freq to the base_frequency.

---
 .../x86/intel-speed-select/isst-config.c      | 21 +++++++++++++++++++
 1 file changed, 21 insertions(+)
tools/power/x86/intel-speed-select/isst-config.c +21 -0
index 5390158cdb40..9b6f0e6f150d 100644
@@ -1249,6 +1249,8 @@ static void dump_isst_config(int arg)
 	isst_ctdp_display_information_end(outf);
 }
 
+static void adjust_scaling_max_from_base_freq(int cpu);
+
 static void set_tdp_level_for_cpu(int cpu, void *arg1, void *arg2, void *arg3,
 				  void *arg4)
 {
@@ -1267,6 +1269,9 @@ static void set_tdp_level_for_cpu(int cpu, void *arg1, void *arg2, void *arg3,
 			int pkg_id = get_physical_package_id(cpu);
 			int die_id = get_physical_die_id(cpu);
 
+			/* Wait for updated base frequencies */
+			usleep(2000);
+
 			fprintf(stderr, "Option is set to online/offline\n");
 			ctdp_level.core_cpumask_size =
 				alloc_cpu_set(&ctdp_level.core_cpumask);
@@ -1283,6 +1288,7 @@ static void set_tdp_level_for_cpu(int cpu, void *arg1, void *arg2, void *arg3,
 					if (CPU_ISSET_S(i, ctdp_level.core_cpumask_size, ctdp_level.core_cpumask)) {
 						fprintf(stderr, "online cpu %d\n", i);
 						set_cpu_online_offline(i, 1);
+						adjust_scaling_max_from_base_freq(i);
 					} else {
 						fprintf(stderr, "offline cpu %d\n", i);
 						set_cpu_online_offline(i, 0);
@@ -1440,6 +1446,21 @@ static int set_cpufreq_scaling_min_max(int cpu, int max, int freq)
 	return 0;
 }
 
+static int no_turbo(void)
+{
+	return parse_int_file(0, "/sys/devices/system/cpu/intel_pstate/no_turbo");
+}
+
+static void adjust_scaling_max_from_base_freq(int cpu)
+{
+	int base_freq, scaling_max_freq;
+
+	scaling_max_freq = parse_int_file(0, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_max_freq", cpu);
+	base_freq = get_cpufreq_base_freq(cpu);
+	if (scaling_max_freq < base_freq || no_turbo())
+		set_cpufreq_scaling_min_max(cpu, 1, base_freq);
+}
+
 static int set_clx_pbf_cpufreq_scaling_min_max(int cpu)
 {
 	struct isst_pkg_ctdp_level_info *ctdp_level;
Signature · 1 line
2.29.2
author maintainer
#2 lore raw

PATCH 2/2 tools/power/x86/intel-speed-select: Set higher of cpuinfo_max_freq or base_frequency

In reply to Srinivas Pandruvada

In some case when BIOS disabled turbo, cpufreq cpuinfo_max_freq can be lower than base_frequency at higher config level. So, in that case set scaling_min_freq to base_frequency.

---
 tools/power/x86/intel-speed-select/isst-config.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
tools/power/x86/intel-speed-select/isst-config.c +11 -0
index 9b6f0e6f150d..09cb3a6672f3 100644
@@ -1461,6 +1461,16 @@ static void adjust_scaling_max_from_base_freq(int cpu)
 		set_cpufreq_scaling_min_max(cpu, 1, base_freq);
 }
 
+static void adjust_scaling_min_from_base_freq(int cpu)
+{
+	int base_freq, scaling_min_freq;
+
+	scaling_min_freq = parse_int_file(0, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_min_freq", cpu);
+	base_freq = get_cpufreq_base_freq(cpu);
+	if (scaling_min_freq < base_freq)
+		set_cpufreq_scaling_min_max(cpu, 0, base_freq);
+}
+
 static int set_clx_pbf_cpufreq_scaling_min_max(int cpu)
 {
 	struct isst_pkg_ctdp_level_info *ctdp_level;
@@ -1558,6 +1568,7 @@ static void set_scaling_min_to_cpuinfo_max(int cpu)
 			continue;
 
 		set_cpufreq_scaling_min_max_from_cpuinfo(i, 1, 0);
+		adjust_scaling_min_from_base_freq(i);
 	}
 }
 
Signature · 1 line
2.29.2
#3 lore raw
In reply to Srinivas Pandruvada

Hi,

Quoted 12 lines · Srinivas Pandruvada

One side-effect of fixing the scaling frequency limits using the commit eacc9c5a927e ("cpufreq: intel_pstate: Fix intel_pstate_get_hwp_max() for turbo disabled") causes stale HWP_CAP.GUARANTEED to be used as max. Without processing HWP interrupts, user space needs to be able to update a new max while Intel SST is in use. This is not a problem as the change of guaranteed is caused by user space action, so user space knows that guarantee will change.

This series causes user space to trigger scaling_max_freq update with the new base_frequency.

Quoted 5 lines

Srinivas Pandruvada (2):
tools/power/x86/intel-speed-select: Set scaling_max_freq to
base_frequency
tools/power/x86/intel-speed-select: Set higher of cpuinfo_max_freq or
base_frequency

Thank you for your patch-series, I've applied the series to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.

Regards,

Hans

#4 lore raw

Hi,

Quoted 25 lines · Hans de Goede

Hi,

Quoted 12 lines · Srinivas Pandruvada

One side-effect of fixing the scaling frequency limits using the commit eacc9c5a927e ("cpufreq: intel_pstate: Fix intel_pstate_get_hwp_max() for turbo disabled") causes stale HWP_CAP.GUARANTEED to be used as max. Without processing HWP interrupts, user space needs to be able to update a new max while Intel SST is in use. This is not a problem as the change of guaranteed is caused by user space action, so user space knows that guarantee will change.

This series causes user space to trigger scaling_max_freq update with the new base_frequency.

Quoted 5 lines

Srinivas Pandruvada (2):
tools/power/x86/intel-speed-select: Set scaling_max_freq to
base_frequency
tools/power/x86/intel-speed-select: Set higher of cpuinfo_max_freq or
base_frequency

Thank you for your patch-series, I've applied the series to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Quoted 7 lines

Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.

Note this is a templated reply, I will also cherry-pick these into the fixes branch in this case.

Regards,

Hans

author maintainer
#5 lore raw

Hi Hans,

Quoted 37 lines · Hans de Goede

Hi,

Quoted 34 lines · Hans de Goede

Hi,

Quoted 17 lines · Srinivas Pandruvada

One side-effect of fixing the scaling frequency limits using the commit eacc9c5a927e ("cpufreq: intel_pstate: Fix intel_pstate_get_hwp_max()
for turbo disabled") causes stale HWP_CAP.GUARANTEED to be used as max.
Without processing HWP interrupts, user space needs to be able to update
a new max while Intel SST is in use. This is not a problem as the change of guaranteed is caused by user space action, so user space knows
that guarantee will change.

This series causes user space to trigger scaling_max_freq update with
the new base_frequency.

Quoted 6 lines

Srinivas Pandruvada (2):
  tools/power/x86/intel-speed-select: Set scaling_max_freq to base_frequency tools/power/x86/intel-speed-select: Set higher of cpuinfo_max_freq or
    base_frequency

Thank you for your patch-series, I've applied the series to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.

Quoted 9 lines
Quoted 4 lines

Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.

Note this is a templated reply, I will also cherry-pick these into the
fixes branch in this case.

Then you can ignore my previous email.

Thanks,
Srinivas

Quoted 4 lines

Regards,

Hans

author maintainer
#6 lore raw
In reply to Hans de Goede
Quoted 32 lines · Hans de Goede

Hi,

Quoted 17 lines · Srinivas Pandruvada

One side-effect of fixing the scaling frequency limits using the commit eacc9c5a927e ("cpufreq: intel_pstate: Fix intel_pstate_get_hwp_max()
for turbo disabled") causes stale HWP_CAP.GUARANTEED to be used as max.
Without processing HWP interrupts, user space needs to be able to update
a new max while Intel SST is in use. This is not a problem as the change of guaranteed is caused by user space action, so user space knows
that guarantee will change.

This series causes user space to trigger scaling_max_freq update with
the new base_frequency.

Quoted 6 lines

Srinivas Pandruvada (2):
  tools/power/x86/intel-speed-select: Set scaling_max_freq to base_frequency tools/power/x86/intel-speed-select: Set higher of cpuinfo_max_freq or
    base_frequency

Thank you for your patch-series, I've applied the series to my review-hans branch:

https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Quoted 7 lines

Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.

I thought of applying these to the next 5.11-rc release.
If you want to queue for the next merge window (5.12) then I have other enhancements, which I will send a PULL request.

Thanks,
Srinivas

Quoted 5 lines

Regards,

Hans