* [PATCH] cpufreq: Fix wrong time unit conversion
@ 2013-09-07 16:35 Frederic Weisbecker
2013-09-07 19:02 ` Paul E. McKenney
2013-09-07 19:59 ` Andreas Schwab
0 siblings, 2 replies; 9+ messages in thread
From: Frederic Weisbecker @ 2013-09-07 16:35 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar
Cc: LKML, Frederic Weisbecker, Carsten Emde, Thomas Gleixner,
Clark Williams, Sebastian Andrzej Siewior, Paul E. McKenney
The time spent by a CPU under a given frequency is stored in jiffies unit
in the cpu var cpufreq_stats_table->time_in_state[i], i being the index of
the frequency.
This is what is displayed in the following file on the right column:
cat /sys/devices/system/cpu/cpuX/cpufreq/stats/time_in_state
2301000 19835820
2300000 3172
[...]
Now cpufreq converts this jiffies unit delta to clock_t before returning it
to the user as in the above file. And that conversion is achieved using the API
cputime64_to_clock_t().
Although it accidentally works on traditional tick based cputime accounting, where
cputime_t maps directly to jiffies, it doesn't work with other types of cputime
accounting such as CONFIG_VIRT_CPU_ACCOUNTING_* where cputime_t can map to nsecs
or any granularity preffered by the architecture.
For example we get a buggy zero delta on full dyntick configurations:
cat /sys/devices/system/cpu/cpuX/cpufreq/stats/time_in_state
2301000 0
2300000 0
[...]
Fix this with using the proper jiffies_64_t to clock_t conversion.
Reported-by: Carsten Emde <C.Emde@osadl.org>
Tested-by: Carsten Emde <C.Emde@osadl.org>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Carsten Emde <C.Emde@osadl.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Clark Williams <williams@redhat.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
drivers/cpufreq/cpufreq_stats.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index d37568c..10e6138 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -81,7 +81,7 @@ static ssize_t show_time_in_state(struct cpufreq_policy *policy, char *buf)
for (i = 0; i < stat->state_num; i++) {
len += sprintf(buf + len, "%u %llu\n", stat->freq_table[i],
(unsigned long long)
- cputime64_to_clock_t(stat->time_in_state[i]));
+ jiffies_64_to_clock_t(stat->time_in_state[i]));
}
return len;
}
--
1.7.5.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] cpufreq: Fix wrong time unit conversion
2013-09-07 16:35 [PATCH] cpufreq: Fix wrong time unit conversion Frederic Weisbecker
@ 2013-09-07 19:02 ` Paul E. McKenney
2013-09-07 21:55 ` Rafael J. Wysocki
2013-09-07 19:59 ` Andreas Schwab
1 sibling, 1 reply; 9+ messages in thread
From: Paul E. McKenney @ 2013-09-07 19:02 UTC (permalink / raw)
To: Frederic Weisbecker
Cc: Rafael J. Wysocki, Viresh Kumar, LKML, Carsten Emde,
Thomas Gleixner, Clark Williams, Sebastian Andrzej Siewior
On Sat, Sep 07, 2013 at 06:35:08PM +0200, Frederic Weisbecker wrote:
> The time spent by a CPU under a given frequency is stored in jiffies unit
> in the cpu var cpufreq_stats_table->time_in_state[i], i being the index of
> the frequency.
>
> This is what is displayed in the following file on the right column:
>
> cat /sys/devices/system/cpu/cpuX/cpufreq/stats/time_in_state
> 2301000 19835820
> 2300000 3172
> [...]
>
> Now cpufreq converts this jiffies unit delta to clock_t before returning it
> to the user as in the above file. And that conversion is achieved using the API
> cputime64_to_clock_t().
>
> Although it accidentally works on traditional tick based cputime accounting, where
> cputime_t maps directly to jiffies, it doesn't work with other types of cputime
> accounting such as CONFIG_VIRT_CPU_ACCOUNTING_* where cputime_t can map to nsecs
> or any granularity preffered by the architecture.
>
> For example we get a buggy zero delta on full dyntick configurations:
>
> cat /sys/devices/system/cpu/cpuX/cpufreq/stats/time_in_state
> 2301000 0
> 2300000 0
> [...]
>
> Fix this with using the proper jiffies_64_t to clock_t conversion.
>
> Reported-by: Carsten Emde <C.Emde@osadl.org>
> Tested-by: Carsten Emde <C.Emde@osadl.org>
> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: Carsten Emde <C.Emde@osadl.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Clark Williams <williams@redhat.com>
> Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Good catch!
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> ---
> drivers/cpufreq/cpufreq_stats.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
> index d37568c..10e6138 100644
> --- a/drivers/cpufreq/cpufreq_stats.c
> +++ b/drivers/cpufreq/cpufreq_stats.c
> @@ -81,7 +81,7 @@ static ssize_t show_time_in_state(struct cpufreq_policy *policy, char *buf)
> for (i = 0; i < stat->state_num; i++) {
> len += sprintf(buf + len, "%u %llu\n", stat->freq_table[i],
> (unsigned long long)
> - cputime64_to_clock_t(stat->time_in_state[i]));
> + jiffies_64_to_clock_t(stat->time_in_state[i]));
> }
> return len;
> }
> --
> 1.7.5.4
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] cpufreq: Fix wrong time unit conversion
2013-09-07 16:35 [PATCH] cpufreq: Fix wrong time unit conversion Frederic Weisbecker
2013-09-07 19:02 ` Paul E. McKenney
@ 2013-09-07 19:59 ` Andreas Schwab
2013-09-08 1:57 ` Paul E. McKenney
2013-09-08 10:25 ` Frederic Weisbecker
1 sibling, 2 replies; 9+ messages in thread
From: Andreas Schwab @ 2013-09-07 19:59 UTC (permalink / raw)
To: Frederic Weisbecker
Cc: Rafael J. Wysocki, Viresh Kumar, LKML, Carsten Emde,
Thomas Gleixner, Clark Williams, Sebastian Andrzej Siewior,
Paul E. McKenney
See also <http://permalink.gmane.org/gmane.linux.kernel.cpufreq/11672>.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] cpufreq: Fix wrong time unit conversion
2013-09-07 19:02 ` Paul E. McKenney
@ 2013-09-07 21:55 ` Rafael J. Wysocki
0 siblings, 0 replies; 9+ messages in thread
From: Rafael J. Wysocki @ 2013-09-07 21:55 UTC (permalink / raw)
To: paulmck, Frederic Weisbecker
Cc: Viresh Kumar, LKML, Carsten Emde, Thomas Gleixner, Clark Williams,
Sebastian Andrzej Siewior
On Saturday, September 07, 2013 12:02:26 PM Paul E. McKenney wrote:
> On Sat, Sep 07, 2013 at 06:35:08PM +0200, Frederic Weisbecker wrote:
> > The time spent by a CPU under a given frequency is stored in jiffies unit
> > in the cpu var cpufreq_stats_table->time_in_state[i], i being the index of
> > the frequency.
> >
> > This is what is displayed in the following file on the right column:
> >
> > cat /sys/devices/system/cpu/cpuX/cpufreq/stats/time_in_state
> > 2301000 19835820
> > 2300000 3172
> > [...]
> >
> > Now cpufreq converts this jiffies unit delta to clock_t before returning it
> > to the user as in the above file. And that conversion is achieved using the API
> > cputime64_to_clock_t().
> >
> > Although it accidentally works on traditional tick based cputime accounting, where
> > cputime_t maps directly to jiffies, it doesn't work with other types of cputime
> > accounting such as CONFIG_VIRT_CPU_ACCOUNTING_* where cputime_t can map to nsecs
> > or any granularity preffered by the architecture.
> >
> > For example we get a buggy zero delta on full dyntick configurations:
> >
> > cat /sys/devices/system/cpu/cpuX/cpufreq/stats/time_in_state
> > 2301000 0
> > 2300000 0
> > [...]
> >
> > Fix this with using the proper jiffies_64_t to clock_t conversion.
> >
> > Reported-by: Carsten Emde <C.Emde@osadl.org>
> > Tested-by: Carsten Emde <C.Emde@osadl.org>
> > Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
> > Cc: Carsten Emde <C.Emde@osadl.org>
> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > Cc: Clark Williams <williams@redhat.com>
> > Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> > Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
>
> Good catch!
>
> Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Applied, will push for 3.12-rc1.
Thanks Frederic!
>
> > ---
> > drivers/cpufreq/cpufreq_stats.c | 2 +-
> > 1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
> > index d37568c..10e6138 100644
> > --- a/drivers/cpufreq/cpufreq_stats.c
> > +++ b/drivers/cpufreq/cpufreq_stats.c
> > @@ -81,7 +81,7 @@ static ssize_t show_time_in_state(struct cpufreq_policy *policy, char *buf)
> > for (i = 0; i < stat->state_num; i++) {
> > len += sprintf(buf + len, "%u %llu\n", stat->freq_table[i],
> > (unsigned long long)
> > - cputime64_to_clock_t(stat->time_in_state[i]));
> > + jiffies_64_to_clock_t(stat->time_in_state[i]));
> > }
> > return len;
> > }
>
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] cpufreq: Fix wrong time unit conversion
2013-09-07 19:59 ` Andreas Schwab
@ 2013-09-08 1:57 ` Paul E. McKenney
2013-09-08 10:25 ` Frederic Weisbecker
1 sibling, 0 replies; 9+ messages in thread
From: Paul E. McKenney @ 2013-09-08 1:57 UTC (permalink / raw)
To: Andreas Schwab
Cc: Frederic Weisbecker, Rafael J. Wysocki, Viresh Kumar, LKML,
Carsten Emde, Thomas Gleixner, Clark Williams,
Sebastian Andrzej Siewior
On Sat, Sep 07, 2013 at 09:59:38PM +0200, Andreas Schwab wrote:
> See also <http://permalink.gmane.org/gmane.linux.kernel.cpufreq/11672>.
Does look quite similar, now that you mention it.
Perhaps if Frederic has not already sent his patch he could add your
Signed-off-by to his patch?
Thanx, Paul
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] cpufreq: Fix wrong time unit conversion
2013-09-07 19:59 ` Andreas Schwab
2013-09-08 1:57 ` Paul E. McKenney
@ 2013-09-08 10:25 ` Frederic Weisbecker
2013-09-08 11:49 ` Rafael J. Wysocki
1 sibling, 1 reply; 9+ messages in thread
From: Frederic Weisbecker @ 2013-09-08 10:25 UTC (permalink / raw)
To: Andreas Schwab
Cc: Rafael J. Wysocki, Viresh Kumar, LKML, Carsten Emde,
Thomas Gleixner, Clark Williams, Sebastian Andrzej Siewior,
Paul E. McKenney
On Sat, Sep 07, 2013 at 09:59:38PM +0200, Andreas Schwab wrote:
> See also <http://permalink.gmane.org/gmane.linux.kernel.cpufreq/11672>.
>
> Andreas.
Ah I missed it.
Raphael, if it is not too late, may be you could still set Andreas as the original author?
Thanks.
>
> --
> Andreas Schwab, schwab@linux-m68k.org
> GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
> "And now for something completely different."
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] cpufreq: Fix wrong time unit conversion
2013-09-08 10:25 ` Frederic Weisbecker
@ 2013-09-08 11:49 ` Rafael J. Wysocki
2013-09-08 11:53 ` Rafael J. Wysocki
0 siblings, 1 reply; 9+ messages in thread
From: Rafael J. Wysocki @ 2013-09-08 11:49 UTC (permalink / raw)
To: Frederic Weisbecker
Cc: Andreas Schwab, Viresh Kumar, LKML, Carsten Emde, Thomas Gleixner,
Clark Williams, Sebastian Andrzej Siewior, Paul E. McKenney
On Sunday, September 08, 2013 12:25:57 PM Frederic Weisbecker wrote:
> On Sat, Sep 07, 2013 at 09:59:38PM +0200, Andreas Schwab wrote:
> > See also <http://permalink.gmane.org/gmane.linux.kernel.cpufreq/11672>.
> >
> > Andreas.
>
> Ah I missed it.
>
> Raphael, if it is not too late, may be you could still set Andreas as the original author?
Done.
Thanks,
Rafael
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] cpufreq: Fix wrong time unit conversion
2013-09-08 11:49 ` Rafael J. Wysocki
@ 2013-09-08 11:53 ` Rafael J. Wysocki
2013-09-08 12:09 ` Frederic Weisbecker
0 siblings, 1 reply; 9+ messages in thread
From: Rafael J. Wysocki @ 2013-09-08 11:53 UTC (permalink / raw)
To: Frederic Weisbecker
Cc: Andreas Schwab, Viresh Kumar, LKML, Carsten Emde, Thomas Gleixner,
Clark Williams, Sebastian Andrzej Siewior, Paul E. McKenney
On Sunday, September 08, 2013 01:49:42 PM Rafael J. Wysocki wrote:
> On Sunday, September 08, 2013 12:25:57 PM Frederic Weisbecker wrote:
> > On Sat, Sep 07, 2013 at 09:59:38PM +0200, Andreas Schwab wrote:
> > > See also <http://permalink.gmane.org/gmane.linux.kernel.cpufreq/11672>.
> > >
> > > Andreas.
> >
> > Ah I missed it.
> >
> > Raphael, if it is not too late, may be you could still set Andreas as the original author?
>
> Done.
BTW, CCing power management patches to linux-pm@vger.kernel.org helps a bit,
because I can see them in patchwork then and that makes overlooking them or
forgetting about them much less likely.
Thanks,
Rafael
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] cpufreq: Fix wrong time unit conversion
2013-09-08 11:53 ` Rafael J. Wysocki
@ 2013-09-08 12:09 ` Frederic Weisbecker
0 siblings, 0 replies; 9+ messages in thread
From: Frederic Weisbecker @ 2013-09-08 12:09 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Andreas Schwab, Viresh Kumar, LKML, Carsten Emde, Thomas Gleixner,
Clark Williams, Sebastian Andrzej Siewior, Paul E. McKenney
On Sun, Sep 08, 2013 at 01:53:13PM +0200, Rafael J. Wysocki wrote:
> On Sunday, September 08, 2013 01:49:42 PM Rafael J. Wysocki wrote:
> > On Sunday, September 08, 2013 12:25:57 PM Frederic Weisbecker wrote:
> > > On Sat, Sep 07, 2013 at 09:59:38PM +0200, Andreas Schwab wrote:
> > > > See also <http://permalink.gmane.org/gmane.linux.kernel.cpufreq/11672>.
> > > >
> > > > Andreas.
> > >
> > > Ah I missed it.
> > >
> > > Raphael, if it is not too late, may be you could still set Andreas as the original author?
> >
> > Done.
>
> BTW, CCing power management patches to linux-pm@vger.kernel.org helps a bit,
> because I can see them in patchwork then and that makes overlooking them or
> forgetting about them much less likely.
Ok, I'll do that next time.
Thanks.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2013-09-08 12:09 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-07 16:35 [PATCH] cpufreq: Fix wrong time unit conversion Frederic Weisbecker
2013-09-07 19:02 ` Paul E. McKenney
2013-09-07 21:55 ` Rafael J. Wysocki
2013-09-07 19:59 ` Andreas Schwab
2013-09-08 1:57 ` Paul E. McKenney
2013-09-08 10:25 ` Frederic Weisbecker
2013-09-08 11:49 ` Rafael J. Wysocki
2013-09-08 11:53 ` Rafael J. Wysocki
2013-09-08 12:09 ` Frederic Weisbecker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox