linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Wei Wang <wvw@google.com>
Cc: wei.vince.wang@gmail.com, Viresh Kumar <viresh.kumar@linaro.org>,
	Quentin Perret <qperret@google.com>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	Daniel Bristot de Oliveira <bristot@redhat.com>,
	Linux PM <linux-pm@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] sched: cpufreq_schedutil: maintain raw cache when next_f is not changed
Date: Fri, 16 Oct 2020 19:01:42 +0200	[thread overview]
Message-ID: <CAJZ5v0in0N6USFqvuLcccpirahj=oOki67+Lq9_5i_q7Ep7T6g@mail.gmail.com> (raw)
In-Reply-To: <20201016163634.857573-1-wvw@google.com>

On Fri, Oct 16, 2020 at 6:36 PM Wei Wang <wvw@google.com> wrote:
>
> Currently, raw cache will be reset when next_f is changed after
> get_next_freq for correctness. However, it may introduce more
> cycles. This patch changes it to maintain the cached value instead of
> dropping it.

IMV you need to be more specific about why this helps.

> This is adapted from https://android-review.googlesource.com/1352810/
>
> Signed-off-by: Wei Wang <wvw@google.com>
> ---
>  kernel/sched/cpufreq_schedutil.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
> index 5ae7b4e6e8d6..ae3ae7fcd027 100644
> --- a/kernel/sched/cpufreq_schedutil.c
> +++ b/kernel/sched/cpufreq_schedutil.c
> @@ -31,6 +31,7 @@ struct sugov_policy {
>         s64                     freq_update_delay_ns;
>         unsigned int            next_freq;
>         unsigned int            cached_raw_freq;
> +       unsigned int            prev_cached_raw_freq;
>
>         /* The next fields are only needed if fast switch cannot be used: */
>         struct                  irq_work irq_work;
> @@ -165,6 +166,7 @@ static unsigned int get_next_freq(struct sugov_policy *sg_policy,
>                 return sg_policy->next_freq;
>
>         sg_policy->need_freq_update = false;
> +       sg_policy->prev_cached_raw_freq = sg_policy->cached_raw_freq;
>         sg_policy->cached_raw_freq = freq;
>         return cpufreq_driver_resolve_freq(policy, freq);
>  }
> @@ -464,8 +466,8 @@ static void sugov_update_single(struct update_util_data *hook, u64 time,
>         if (busy && next_f < sg_policy->next_freq) {
>                 next_f = sg_policy->next_freq;
>
> -               /* Reset cached freq as next_freq has changed */
> -               sg_policy->cached_raw_freq = 0;
> +               /* Restore cached freq as next_freq has changed */
> +               sg_policy->cached_raw_freq = sg_policy->prev_cached_raw_freq;
>         }
>
>         /*
> @@ -828,6 +830,7 @@ static int sugov_start(struct cpufreq_policy *policy)
>         sg_policy->limits_changed               = false;
>         sg_policy->need_freq_update             = false;
>         sg_policy->cached_raw_freq              = 0;
> +       sg_policy->prev_cached_raw_freq         = 0;
>
>         for_each_cpu(cpu, policy->cpus) {
>                 struct sugov_cpu *sg_cpu = &per_cpu(sugov_cpu, cpu);
> --
> 2.29.0.rc1.297.gfa9743e501-goog
>

  reply	other threads:[~2020-10-16 17:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-16 16:36 [PATCH] sched: cpufreq_schedutil: maintain raw cache when next_f is not changed Wei Wang
2020-10-16 17:01 ` Rafael J. Wysocki [this message]
2020-10-16 17:17   ` Wei Wang
2020-10-16 17:36     ` Rafael J. Wysocki
2020-10-16 17:48       ` Wei Wang
2020-10-16 18:17         ` [PATCH] sched: cpufreq_schedutil: restore cached freq " Wei Wang
2020-10-19  5:09           ` Viresh Kumar
2020-10-19 15:39           ` 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='CAJZ5v0in0N6USFqvuLcccpirahj=oOki67+Lq9_5i_q7Ep7T6g@mail.gmail.com' \
    --to=rafael@kernel.org \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=qperret@google.com \
    --cc=rjw@rjwysocki.net \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    --cc=viresh.kumar@linaro.org \
    --cc=wei.vince.wang@gmail.com \
    --cc=wvw@google.com \
    /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 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).