linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: Bo Yan <byan@nvidia.com>
Cc: rjw@rjwysocki.net, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] cpufreq: cpufreq_stats: make last_index signed int
Date: Tue, 19 Sep 2017 11:54:47 -0700	[thread overview]
Message-ID: <20170919185447.GC30848@ubuntu> (raw)
In-Reply-To: <961bce0a-5162-5e8d-3474-5b2161cf92c4@nvidia.com>

On 18-09-17, 10:39, Bo Yan wrote:
> Currently, the "last_index" is being checked before
> cpufreq_stats_update(stats) inside function
> "cpufreq_stats_record_transition", so it's taken care of.
> 
> However, the function "show_time_in_state" also calls cpufreq_stats_update,
> the similar check should be done there too, like this:

Yeah, that's what I suggested.

> diff --git a/drivers/cpufreq/cpufreq_stats.c
> b/drivers/cpufreq/cpufreq_stats.c
> index e75880eb037d..15305b5ec322 100644
> --- a/drivers/cpufreq/cpufreq_stats.c
> +++ b/drivers/cpufreq/cpufreq_stats.c
> @@ -62,7 +62,8 @@ static ssize_t show_time_in_state(struct cpufreq_policy
> *policy, char *buf)
>         if (policy->fast_switch_enabled)
>                 return 0;
> 
> -       cpufreq_stats_update(stats);
> +       if ((int)stats->last_index >= 0)

You can rather do:

        if (stats->last_index != -1)

> +               cpufreq_stats_update(stats);
>         for (i = 0; i < stats->state_num; i++) {
>                 len += sprintf(buf + len, "%u %llu\n", stats->freq_table[i],
>                         (unsigned long long)
> 
> 
> This is only needed when policy->cur is not in frequency table when stats
> table is created, in which case, stats->last_index will get -1, then user
> does a "cat time_in_state" before any frequency transition.
> 
> Does this make sense?

-- 
viresh

      reply	other threads:[~2017-09-19 18:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-15 20:13 [PATCH] cpufreq: cpufreq_stats: make last_index signed int Bo Yan
2017-09-18  1:50 ` Viresh Kumar
2017-09-18 17:39   ` Bo Yan
2017-09-19 18:54     ` Viresh Kumar [this message]

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=20170919185447.GC30848@ubuntu \
    --to=viresh.kumar@linaro.org \
    --cc=byan@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    /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).