All of lore.kernel.org
 help / color / mirror / Atom feed
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Len Brown <lenb@kernel.org>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	Linux PM <linux-pm@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] cpufreq: intel_pstate: Use the latest guaranteed freq during verify
Date: Thu, 17 Dec 2020 06:19:13 -0800	[thread overview]
Message-ID: <d581bfe77c2fc4ff266bb155cf610f176c786e2e.camel@linux.intel.com> (raw)
In-Reply-To: <CAJZ5v0ghXA=mao_S-VH-x0_0uvGYK_oWj10f-A=u0w82tXDg5Q@mail.gmail.com>

On Thu, 2020-12-17 at 14:58 +0100, Rafael J. Wysocki wrote:
> On Thu, Dec 17, 2020 at 11:44 AM Srinivas Pandruvada
> <srinivas.pandruvada@linux.intel.com> wrote:
> > 
> > This change tries to address an issue, when BIOS disabled turbo
> > but HWP_CAP guaranteed is changed later and user space wants to
> > take
> > advantage of this increased guaranteed performance.
> > 
> > The HWP_CAP.GUARANTEED value is not a static value. It can be
> > changed
> > by some out of band agent or during Intel Speed Select performance
> > level change. The HWP_CAP.MAX still shows max possible performance
> > when
> > BIOS disabled turbo. So guaranteed can still change as long as this
> > is
> > same or below HWP_CAP.MAX.
> > 
> > When guaranteed is changed, the sysfs base_frequency attributes
> > shows
> > the latest guaranteed frequency. This attribute can be used by user
> > space software to update scaling min/max frequency.
> > 
> > Currently the setpolicy callback already uses the latest HWP_CAP
> > values when setting HWP_REQ. But the verify callback will still
> > restrict
> > the user settings to the to old guaranteed value. So if the
> > guaranteed
> > is increased, user space can't take advantage of it.
> > 
> > To solve this similar to setpolicy callback, read the latest
> > HWP_CAP
> > values and use it to restrict the maximum setting. This is done by
> > calling intel_pstate_get_hwp_max(), which already accounts for user
> > and BIOS turbo disable to get the current max performance.
> > 
> > This issue is side effect of fixing the issue of scaling frequency
> > limits by the
> >  'commit eacc9c5a927e ("cpufreq: intel_pstate:
> >  Fix intel_pstate_get_hwp_max() for turbo disabled")'
> > The fix resulted in correct setting of reduced scaling frequencies,
> > but this resulted in capping HWP.REQ to HWP_CAP.GUARANTEED in this
> > case.
> > 
> > Cc: 5.8+ <stable@vger.kernel.org> # 5.8+
> > Signed-off-by: Srinivas Pandruvada <
> > srinivas.pandruvada@linux.intel.com>
> > ---
> >  drivers/cpufreq/intel_pstate.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/drivers/cpufreq/intel_pstate.c
> > b/drivers/cpufreq/intel_pstate.c
> > index 2a4db856222f..7081d1edb22b 100644
> > --- a/drivers/cpufreq/intel_pstate.c
> > +++ b/drivers/cpufreq/intel_pstate.c
> > @@ -2199,6 +2199,12 @@ static void
> > intel_pstate_clear_update_util_hook(unsigned int cpu)
> > 
> >  static int intel_pstate_get_max_freq(struct cpudata *cpu)
> >  {
> > +       if (hwp_active) {
> > +               int turbo_max, max_state;
> > +
> > +               intel_pstate_get_hwp_max(cpu->cpu, &turbo_max,
> > &max_state);
> 
> This would cause intel_pstate_get_hwp_max() to be called twice in
> intel_pstate_update_perf_limits() which is not perfect.

We can optimize by using cached value.


diff --git a/drivers/cpufreq/intel_pstate.c
b/drivers/cpufreq/intel_pstate.c
index 7081d1edb22b..d345c9ef240c 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -2223,7 +2223,11 @@ static void
intel_pstate_update_perf_limits(struct cpudata *cpu,
         * rather than pure ratios.
         */
        if (hwp_active) {
-               intel_pstate_get_hwp_max(cpu->cpu, &turbo_max,
&max_state);
+               if (global.no_turbo || global.turbo_disabled)
+                       max_state = HWP_GUARANTEED_PERF(cpu-
>hwp_cap_cached);
+               else
+                       max_state = HWP_HIGHEST_PERF(cpu-
>hwp_cap_cached);
+               turbo_max = HWP_HIGHEST_PERF(cpu->hwp_cached);
        } else {
                max_state = global.no_turbo || global.turbo_disabled ?
                        cpu->pstate.max_pstate : cpu-
>pstate.turbo_pstate;


Thanks,
Srinivas


> 
> > +               return max_state * cpu->pstate.scaling;
> > +       }
> >         return global.turbo_disabled || global.no_turbo ?
> >                         cpu->pstate.max_freq : cpu-
> > >pstate.turbo_freq;
> >  }
> > --



  reply	other threads:[~2020-12-17 14:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-17 10:42 [PATCH] cpufreq: intel_pstate: Use the latest guaranteed freq during verify Srinivas Pandruvada
2020-12-17 13:58 ` Rafael J. Wysocki
2020-12-17 14:19   ` Srinivas Pandruvada [this message]
2020-12-17 14:23     ` Srinivas Pandruvada
2020-12-17 15:12       ` Rafael J. Wysocki
2020-12-17 15:21         ` Srinivas Pandruvada
2020-12-17 15:24           ` Rafael J. Wysocki
2020-12-17 17:09             ` Srinivas Pandruvada
2020-12-17 17:29               ` Rafael J. Wysocki
2020-12-17 19:02                 ` Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d581bfe77c2fc4ff266bb155cf610f176c786e2e.camel@linux.intel.com \
    --to=srinivas.pandruvada@linux.intel.com \
    --cc=lenb@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.