* [PATCH] ARM: OMAP: sched_clock() corrected
@ 2009-02-17 18:21 Aaro Koskinen
2009-02-18 23:39 ` Tony Lindgren
0 siblings, 1 reply; 2+ messages in thread
From: Aaro Koskinen @ 2009-02-17 18:21 UTC (permalink / raw)
To: linux-omap
After my OMAP3 board has been running for a while, I'm seeing weird
latency traces like this:
sh-1574 0d.h2 153us : do_timer (tick_do_update_jiffies64)
sh-1574 0d.h2 153us : update_wall_time (do_timer)
sh-1574 0d.h2 153us!: omap_32k_read (update_wall_time)
sh-1574 0d.h2 1883us : update_xtime_cache (update_wall_time)
sh-1574 0d.h2 1883us : clocksource_get_next (update_wall_time)
sh-1574 0d.h2 1883us+: _spin_lock_irqsave (clocksource_get_next)
and after a while:
sh-17818 0d.h3 153us : do_timer (tick_do_update_jiffies64)
sh-17818 0d.h3 153us : update_wall_time (do_timer)
sh-17818 0d.h3 153us!: omap_32k_read (update_wall_time)
sh-17818 0d.h3 1915us : update_xtime_cache (update_wall_time)
sh-17818 0d.h3 1915us+: clocksource_get_next (update_wall_time)
sh-17818 0d.h3 1945us : _spin_lock_irqsave (clocksource_get_next)
Turns out that sched_clock() is using cyc2ns(), which returns NTP
adjusted time. The sched_clock() frequency should not be adjusted. The
patch deletes omap_32k_ticks_to_nsecs() and rewrites sched_clock()
to do the conversion using the constant multiplier.
Signed-off-by: Aaro Koskinen <Aaro.Koskinen@nokia.com>
---
arch/arm/plat-omap/common.c | 14 +++++---------
1 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/arch/arm/plat-omap/common.c b/arch/arm/plat-omap/common.c
index 8c53125..2866612 100644
--- a/arch/arm/plat-omap/common.c
+++ b/arch/arm/plat-omap/common.c
@@ -220,20 +220,16 @@ static struct clocksource clocksource_32k = {
};
/*
- * Rounds down to nearest nsec.
- */
-unsigned long long omap_32k_ticks_to_nsecs(unsigned long ticks_32k)
-{
- return cyc2ns(&clocksource_32k, ticks_32k);
-}
-
-/*
* Returns current time from boot in nsecs. It's OK for this to wrap
* around for now, as it's just a relative time stamp.
*/
unsigned long long sched_clock(void)
{
- return omap_32k_ticks_to_nsecs(omap_32k_read());
+ unsigned long long ret;
+
+ ret = (unsigned long long)omap_32k_read();
+ ret = (ret * clocksource_32k.mult_orig) >> clocksource_32k.shift;
+ return ret;
}
static int __init omap_init_clocksource_32k(void)
--
1.5.4.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ARM: OMAP: sched_clock() corrected
2009-02-17 18:21 [PATCH] ARM: OMAP: sched_clock() corrected Aaro Koskinen
@ 2009-02-18 23:39 ` Tony Lindgren
0 siblings, 0 replies; 2+ messages in thread
From: Tony Lindgren @ 2009-02-18 23:39 UTC (permalink / raw)
To: Aaro Koskinen; +Cc: linux-omap
* Aaro Koskinen <Aaro.Koskinen@nokia.com> [090217 10:27]:
> After my OMAP3 board has been running for a while, I'm seeing weird
> latency traces like this:
>
> sh-1574 0d.h2 153us : do_timer (tick_do_update_jiffies64)
> sh-1574 0d.h2 153us : update_wall_time (do_timer)
> sh-1574 0d.h2 153us!: omap_32k_read (update_wall_time)
> sh-1574 0d.h2 1883us : update_xtime_cache (update_wall_time)
> sh-1574 0d.h2 1883us : clocksource_get_next (update_wall_time)
> sh-1574 0d.h2 1883us+: _spin_lock_irqsave (clocksource_get_next)
>
> and after a while:
>
> sh-17818 0d.h3 153us : do_timer (tick_do_update_jiffies64)
> sh-17818 0d.h3 153us : update_wall_time (do_timer)
> sh-17818 0d.h3 153us!: omap_32k_read (update_wall_time)
> sh-17818 0d.h3 1915us : update_xtime_cache (update_wall_time)
> sh-17818 0d.h3 1915us+: clocksource_get_next (update_wall_time)
> sh-17818 0d.h3 1945us : _spin_lock_irqsave (clocksource_get_next)
>
> Turns out that sched_clock() is using cyc2ns(), which returns NTP
> adjusted time. The sched_clock() frequency should not be adjusted. The
> patch deletes omap_32k_ticks_to_nsecs() and rewrites sched_clock()
> to do the conversion using the constant multiplier.
Nice catch! Applying to linux-omap and omap-fixes.
Tony
> Signed-off-by: Aaro Koskinen <Aaro.Koskinen@nokia.com>
> ---
> arch/arm/plat-omap/common.c | 14 +++++---------
> 1 files changed, 5 insertions(+), 9 deletions(-)
>
> diff --git a/arch/arm/plat-omap/common.c b/arch/arm/plat-omap/common.c
> index 8c53125..2866612 100644
> --- a/arch/arm/plat-omap/common.c
> +++ b/arch/arm/plat-omap/common.c
> @@ -220,20 +220,16 @@ static struct clocksource clocksource_32k = {
> };
>
> /*
> - * Rounds down to nearest nsec.
> - */
> -unsigned long long omap_32k_ticks_to_nsecs(unsigned long ticks_32k)
> -{
> - return cyc2ns(&clocksource_32k, ticks_32k);
> -}
> -
> -/*
> * Returns current time from boot in nsecs. It's OK for this to wrap
> * around for now, as it's just a relative time stamp.
> */
> unsigned long long sched_clock(void)
> {
> - return omap_32k_ticks_to_nsecs(omap_32k_read());
> + unsigned long long ret;
> +
> + ret = (unsigned long long)omap_32k_read();
> + ret = (ret * clocksource_32k.mult_orig) >> clocksource_32k.shift;
> + return ret;
> }
>
> static int __init omap_init_clocksource_32k(void)
> --
> 1.5.4.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-02-18 23:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-17 18:21 [PATCH] ARM: OMAP: sched_clock() corrected Aaro Koskinen
2009-02-18 23:39 ` Tony Lindgren
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox