All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tony Lindgren <tony@atomide.com>
To: linux-arm-kernel@lists.arm.linux.org.uk
Cc: linux-omap@vger.kernel.org, Aaro Koskinen <Aaro.Koskinen@nokia.com>
Subject: [PATCH 2/4] ARM: OMAP: sched_clock() corrected
Date: Wed, 04 Mar 2009 10:27:53 -0800	[thread overview]
Message-ID: <20090304182753.27331.99951.stgit@localhost> (raw)
In-Reply-To: <20090304182342.27331.35004.stgit@localhost>

From: Aaro Koskinen <Aaro.Koskinen@nokia.com>

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>
Signed-off-by: Tony Lindgren <tony@atomide.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 0843b88..6825fbb 100644
--- a/arch/arm/plat-omap/common.c
+++ b/arch/arm/plat-omap/common.c
@@ -200,20 +200,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)


  parent reply	other threads:[~2009-03-04 18:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-04 18:25 [PATCH 0/4] Still more omap fixes for current -rc series Tony Lindgren
2009-03-04 18:26 ` [PATCH 1/4] ARM: OMAP: Fix compile error if pm.h is included Tony Lindgren
2009-03-04 18:27 ` Tony Lindgren [this message]
2009-03-04 18:29 ` [PATCH 3/4] ARM: OMAP: Allow I2C bus driver to be compiled as a module Tony Lindgren
2009-03-04 18:30 ` [PATCH 4/4] ARM: OMAP: board-omap3beagle: set i2c-3 to 100kHz Tony Lindgren
2009-03-07 15:55 ` [PATCH 0/4] Still more omap fixes for current -rc series Tony Lindgren

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=20090304182753.27331.99951.stgit@localhost \
    --to=tony@atomide.com \
    --cc=Aaro.Koskinen@nokia.com \
    --cc=linux-arm-kernel@lists.arm.linux.org.uk \
    --cc=linux-omap@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.