diff mbox

[V2,04/14] cpufreq: stats: pass 'stat' to cpufreq_stats_update()

Message ID aec0c2c88ed01f32e2b5ea60c21f194b8049ef0f.1420177186.git.viresh.kumar@linaro.org
State New
Headers show

Commit Message

Viresh Kumar Jan. 2, 2015, 5:46 a.m. UTC
cpufreq_stats_update() needs only 'stat' pointer for its use and nothing else.
Currently it works fine as we have a per-cpu variable for storing stats. But
later commits would remove it and hence we better pass 'stat' to
cpufreq_stats_update().

Reviewed-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/cpufreq_stats.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

Comments

Viresh Kumar Jan. 5, 2015, 4:04 a.m. UTC | #1
On 4 January 2015 at 03:34, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
> What about:
>
> "It is better to pass a struct cpufreq_stats pointer to cpufreq_stats_update()
>  instead of a CPU number, because ..."

Sure.

>> +static int cpufreq_stats_update(struct cpufreq_stats *stat)
>>  {
>> -     struct cpufreq_stats *stat;
>> -     unsigned long long cur_time;
>> +     unsigned long long cur_time = get_jiffies_64();
>>
>> -     cur_time = get_jiffies_64();
>
> Unrelated change.

Yeah, it was too small of a change so not that significant as well.
And so folded it into this commit only :(

Will send it separately in v3..
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Viresh Kumar Jan. 5, 2015, 7:25 a.m. UTC | #2
On 5 January 2015 at 12:44, Luigi Fioretti <luigi.fioretti@dinema.it> wrote:
> Hi,
> thanks for your help but I don't think to be solution.
> I had apply this patch :
>
> http://lists.infradead.org/pipermail/linux-arm-kernel/2010-December/036055.html
>
> You can read the first problems here:
> http://lists.linaro.org/pipermail/linaro-kernel/2014-March/012635.html
>
> I had found a solution to this problem, and I write to you into my first
> e-mail.
> Now I have this problems:
> When resume  and run this function

What does all this has to do with the mail below ?

> -----linaro-kernel-bounces@lists.linaro.org ha scritto: -----
> Per: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Da: Viresh Kumar
> Inviato da: linaro-kernel-bounces@lists.linaro.org
> Data: 05/01/2015 05.05AM
> Cc: Prarit Bhargava <prarit@redhat.com>, Lists linaro-kernel
> <linaro-kernel@lists.linaro.org>, Saravana Kannan <skannan@codeaurora.org>,
> "linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>
> Oggetto: Re: [PATCH V2 04/14] cpufreq: stats: pass 'stat' to
> cpufreq_stats_update() *
>
> On 4 January 2015 at 03:34, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
>> What about:
>>
>> "It is better to pass a struct cpufreq_stats pointer to
>> cpufreq_stats_update()
>>  instead of a CPU number, because ..."
>
> Sure.
>
>>> +static int cpufreq_stats_update(struct cpufreq_stats *stat)
>>>  {
>>> -     struct cpufreq_stats *stat;
>>> -     unsigned long long cur_time;
>>> +     unsigned long long cur_time = get_jiffies_64();
>>>
>>> -     cur_time = get_jiffies_64();
>>
>> Unrelated change.
>
> Yeah, it was too small of a change so not that significant as well.
> And so folded it into this commit only :(
>
> Will send it separately in v3..
>
> _______________________________________________
> linaro-kernel mailing list
> linaro-kernel@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/linaro-kernel
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index 62b6133f06aa..ebd9e4c5c124 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -38,14 +38,11 @@  struct cpufreq_stats_attribute {
 	ssize_t(*show) (struct cpufreq_stats *, char *);
 };
 
-static int cpufreq_stats_update(unsigned int cpu)
+static int cpufreq_stats_update(struct cpufreq_stats *stat)
 {
-	struct cpufreq_stats *stat;
-	unsigned long long cur_time;
+	unsigned long long cur_time = get_jiffies_64();
 
-	cur_time = get_jiffies_64();
 	spin_lock(&cpufreq_stats_lock);
-	stat = per_cpu(cpufreq_stats_table, cpu);
 	if (stat->time_in_state)
 		stat->time_in_state[stat->last_index] +=
 			cur_time - stat->last_time;
@@ -70,7 +67,7 @@  static ssize_t show_time_in_state(struct cpufreq_policy *policy, char *buf)
 	struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, policy->cpu);
 	if (!stat)
 		return 0;
-	cpufreq_stats_update(stat->cpu);
+	cpufreq_stats_update(stat);
 	for (i = 0; i < stat->state_num; i++) {
 		len += sprintf(buf + len, "%u %llu\n", stat->freq_table[i],
 			(unsigned long long)
@@ -88,7 +85,7 @@  static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf)
 	struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, policy->cpu);
 	if (!stat)
 		return 0;
-	cpufreq_stats_update(stat->cpu);
+	cpufreq_stats_update(stat);
 	len += snprintf(buf + len, PAGE_SIZE - len, "   From  :    To\n");
 	len += snprintf(buf + len, PAGE_SIZE - len, "         : ");
 	for (i = 0; i < stat->state_num; i++) {
@@ -313,7 +310,7 @@  static int cpufreq_stat_notifier_trans(struct notifier_block *nb,
 	if (old_index == -1 || new_index == -1)
 		return 0;
 
-	cpufreq_stats_update(freq->cpu);
+	cpufreq_stats_update(stat);
 
 	if (old_index == new_index)
 		return 0;