linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* tools/power/x86/intel-speed-select: Fixes for regression
@ 2020-12-21  7:18 Srinivas Pandruvada
  2020-12-21  7:18 ` [PATCH 1/2] tools/power/x86/intel-speed-select: Set scaling_max_freq to base_frequency Srinivas Pandruvada
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Srinivas Pandruvada @ 2020-12-21  7:18 UTC (permalink / raw)
  To: hdegoede, mgross; +Cc: platform-driver-x86, linux-kernel, 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.


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(+)

-- 
2.29.2


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] tools/power/x86/intel-speed-select: Set scaling_max_freq to base_frequency
  2020-12-21  7:18 tools/power/x86/intel-speed-select: Fixes for regression Srinivas Pandruvada
@ 2020-12-21  7:18 ` Srinivas Pandruvada
  2020-12-21  7:18 ` [PATCH 2/2] tools/power/x86/intel-speed-select: Set higher of cpuinfo_max_freq or base_frequency Srinivas Pandruvada
  2021-01-04 11:56 ` tools/power/x86/intel-speed-select: Fixes for regression Hans de Goede
  2 siblings, 0 replies; 7+ messages in thread
From: Srinivas Pandruvada @ 2020-12-21  7:18 UTC (permalink / raw)
  To: hdegoede, mgross; +Cc: platform-driver-x86, linux-kernel, Srinivas Pandruvada

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.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 .../x86/intel-speed-select/isst-config.c      | 21 +++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c
index 5390158cdb40..9b6f0e6f150d 100644
--- a/tools/power/x86/intel-speed-select/isst-config.c
+++ b/tools/power/x86/intel-speed-select/isst-config.c
@@ -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;
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] tools/power/x86/intel-speed-select: Set higher of cpuinfo_max_freq or base_frequency
  2020-12-21  7:18 tools/power/x86/intel-speed-select: Fixes for regression Srinivas Pandruvada
  2020-12-21  7:18 ` [PATCH 1/2] tools/power/x86/intel-speed-select: Set scaling_max_freq to base_frequency Srinivas Pandruvada
@ 2020-12-21  7:18 ` Srinivas Pandruvada
  2021-01-04 11:56 ` tools/power/x86/intel-speed-select: Fixes for regression Hans de Goede
  2 siblings, 0 replies; 7+ messages in thread
From: Srinivas Pandruvada @ 2020-12-21  7:18 UTC (permalink / raw)
  To: hdegoede, mgross; +Cc: platform-driver-x86, linux-kernel, 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.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 tools/power/x86/intel-speed-select/isst-config.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c
index 9b6f0e6f150d..09cb3a6672f3 100644
--- a/tools/power/x86/intel-speed-select/isst-config.c
+++ b/tools/power/x86/intel-speed-select/isst-config.c
@@ -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);
 	}
 }
 
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: tools/power/x86/intel-speed-select: Fixes for regression
  2020-12-21  7:18 tools/power/x86/intel-speed-select: Fixes for regression Srinivas Pandruvada
  2020-12-21  7:18 ` [PATCH 1/2] tools/power/x86/intel-speed-select: Set scaling_max_freq to base_frequency Srinivas Pandruvada
  2020-12-21  7:18 ` [PATCH 2/2] tools/power/x86/intel-speed-select: Set higher of cpuinfo_max_freq or base_frequency Srinivas Pandruvada
@ 2021-01-04 11:56 ` Hans de Goede
  2021-01-04 11:57   ` Hans de Goede
  2021-01-04 12:00   ` Srinivas Pandruvada
  2 siblings, 2 replies; 7+ messages in thread
From: Hans de Goede @ 2021-01-04 11:56 UTC (permalink / raw)
  To: Srinivas Pandruvada, mgross; +Cc: platform-driver-x86, linux-kernel

Hi,

On 12/21/20 8:18 AM, Srinivas Pandruvada wrote:
> 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

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: tools/power/x86/intel-speed-select: Fixes for regression
  2021-01-04 11:56 ` tools/power/x86/intel-speed-select: Fixes for regression Hans de Goede
@ 2021-01-04 11:57   ` Hans de Goede
  2021-01-04 12:01     ` Srinivas Pandruvada
  2021-01-04 12:00   ` Srinivas Pandruvada
  1 sibling, 1 reply; 7+ messages in thread
From: Hans de Goede @ 2021-01-04 11:57 UTC (permalink / raw)
  To: Srinivas Pandruvada, mgross; +Cc: platform-driver-x86, linux-kernel

Hi,

On 1/4/21 12:56 PM, Hans de Goede wrote:
> Hi,
> 
> On 12/21/20 8:18 AM, Srinivas Pandruvada wrote:
>> 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
> 
> 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.

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

Regards,

Hans


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: tools/power/x86/intel-speed-select: Fixes for regression
  2021-01-04 11:56 ` tools/power/x86/intel-speed-select: Fixes for regression Hans de Goede
  2021-01-04 11:57   ` Hans de Goede
@ 2021-01-04 12:00   ` Srinivas Pandruvada
  1 sibling, 0 replies; 7+ messages in thread
From: Srinivas Pandruvada @ 2021-01-04 12:00 UTC (permalink / raw)
  To: Hans de Goede, mgross; +Cc: platform-driver-x86, linux-kernel

On Mon, 2021-01-04 at 12:56 +0100, Hans de Goede wrote:
> Hi,
> 
> On 12/21/20 8:18 AM, Srinivas Pandruvada wrote:
> > 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
> 
> 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.
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

> 
> Regards,
> 
> Hans
> 



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: tools/power/x86/intel-speed-select: Fixes for regression
  2021-01-04 11:57   ` Hans de Goede
@ 2021-01-04 12:01     ` Srinivas Pandruvada
  0 siblings, 0 replies; 7+ messages in thread
From: Srinivas Pandruvada @ 2021-01-04 12:01 UTC (permalink / raw)
  To: Hans de Goede, mgross; +Cc: platform-driver-x86, linux-kernel

Hi Hans,

On Mon, 2021-01-04 at 12:57 +0100, Hans de Goede wrote:
> Hi,
> 
> On 1/4/21 12:56 PM, Hans de Goede wrote:
> > Hi,
> > 
> > On 12/21/20 8:18 AM, Srinivas Pandruvada wrote:
> > > 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
> > 
> > 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.
> 
> 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

> Regards,
> 
> Hans
> 



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-01-04 12:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-21  7:18 tools/power/x86/intel-speed-select: Fixes for regression Srinivas Pandruvada
2020-12-21  7:18 ` [PATCH 1/2] tools/power/x86/intel-speed-select: Set scaling_max_freq to base_frequency Srinivas Pandruvada
2020-12-21  7:18 ` [PATCH 2/2] tools/power/x86/intel-speed-select: Set higher of cpuinfo_max_freq or base_frequency Srinivas Pandruvada
2021-01-04 11:56 ` tools/power/x86/intel-speed-select: Fixes for regression Hans de Goede
2021-01-04 11:57   ` Hans de Goede
2021-01-04 12:01     ` Srinivas Pandruvada
2021-01-04 12:00   ` Srinivas Pandruvada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).