From: john stultz <johnstul@us.ibm.com>
To: Andrew Lutomirski <luto@mit.edu>
Cc: Thomas Gleixner <tglx@linutronix.de>,
linux-kernel@vger.kernel.org, pc@us.ibm.com
Subject: Re: [PATCH] Improve clocksource unstable warning
Date: Fri, 12 Nov 2010 16:58:51 -0800 [thread overview]
Message-ID: <1289609931.3292.87.camel@localhost.localdomain> (raw)
In-Reply-To: <1289607722.3292.84.camel@localhost.localdomain>
On Sat, 2010-11-13 at 00:22 +0000, john stultz wrote:
> On Fri, 2010-11-12 at 18:51 -0500, Andrew Lutomirski wrote:
> > Also wrong if cs_elapsed is just slightly less than wd_wrapping_time
> > but the wd clocksource runs enough faster that it wrapped.
>
> Ok. Good point, that's a problem. Hrmmmm. Too much math for Friday. :)
I have a hard time leaving things alone. :)
So this still has the issue of the u64%u64 won't work on 32bit systems,
but I think once I rework the modulo bit the following should be what
you were describing.
It is ugly, so let me know if you have a cleaner way.
Signed-off-by: John Stultz <johnstul@us.ibm.com>
diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index c18d7ef..0afbcb5 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -247,6 +247,7 @@ static void clocksource_watchdog(unsigned long data)
struct clocksource *cs;
cycle_t csnow, wdnow;
int64_t wd_nsec, cs_nsec;
+ int64_t wd_max_nsec;
int next_cpu;
spin_lock(&watchdog_lock);
@@ -257,6 +258,8 @@ static void clocksource_watchdog(unsigned long data)
wd_nsec = clocksource_cyc2ns((wdnow - watchdog_last) & watchdog->mask,
watchdog->mult, watchdog->shift);
watchdog_last = wdnow;
+ wd_max_nsec = clocksource_cyc2ns(watchdog->mask, watchdog->mult,
+ watchdog->shift);
list_for_each_entry(cs, &watchdog_list, wd_list) {
@@ -280,6 +283,35 @@ static void clocksource_watchdog(unsigned long data)
cs_nsec = clocksource_cyc2ns((csnow - cs->wd_last) &
cs->mask, cs->mult, cs->shift);
cs->wd_last = csnow;
+
+ /*
+ * If the cs interval is greater then the wd wrap interval,
+ * we were somehow delayed. So check that modulo the wrap
+ * interval, the cs interval is close to the watchdog
+ * interval value.
+ */
+ if (cs_nsec > wd_max_nsec){
+ int64_t cs_modulo = cs_nsec % wd_max_nsec;
+
+ /* first check the easy case */
+ if(abs(cs_modulo - wd_nsec) < WATCHDOG_THRESHOLD) {
+ WARN_ONCE(1, "clocksource_watchdog:"
+ "watchdog delayed?\n");
+ continue;
+ }
+ /* could be split along the wd_max_nsec boundary*/
+ if (wd_nsec < cs_modulo)
+ wd_nsec += wd_max_nsec;
+ else
+ cs_modulo += wd_max_nsec;
+ /* check again */
+ if(abs(cs_modulo - wd_nsec) < WATCHDOG_THRESHOLD) {
+ WARN_ONCE(1, "clocksource_watchdog:"
+ "watchdog delayed?\n");
+ continue;
+ }
+ }
+
if (abs(cs_nsec - wd_nsec) > WATCHDOG_THRESHOLD) {
clocksource_unstable(cs, cs_nsec - wd_nsec);
continue;
next prev parent reply other threads:[~2010-11-13 0:59 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-10 22:16 [PATCH] Improve clocksource unstable warning Andy Lutomirski
2010-11-10 22:28 ` Thomas Gleixner
2010-11-10 22:42 ` [PATCH v2] " Andy Lutomirski
2010-11-12 21:31 ` [PATCH] " john stultz
2010-11-12 21:51 ` john stultz
2010-11-12 21:52 ` Andrew Lutomirski
2010-11-12 23:40 ` john stultz
2010-11-12 23:48 ` Andrew Lutomirski
2010-11-12 23:51 ` Andrew Lutomirski
2010-11-13 0:22 ` john stultz
2010-11-13 0:58 ` john stultz [this message]
2010-11-17 0:05 ` Andrew Lutomirski
2010-11-17 0:26 ` john stultz
2010-11-17 0:54 ` Andrew Lutomirski
2010-11-17 1:19 ` john stultz
2010-11-17 1:24 ` Andrew Lutomirski
2010-11-17 1:54 ` john stultz
2010-11-12 23:52 ` john stultz
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=1289609931.3292.87.camel@localhost.localdomain \
--to=johnstul@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@mit.edu \
--cc=pc@us.ibm.com \
--cc=tglx@linutronix.de \
/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