public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Daniel Walker <dwalker@mvista.com>
To: mingo@elte.hu
Cc: linux-kernel@vger.kernel.org, johnstul@us.ibm.com
Subject: -rt tsc frequency check
Date: Tue, 05 Dec 2006 17:06:04 -0800	[thread overview]
Message-ID: <20061206010604.916239000@mvista.com> (raw)

I'm not sure about this code. It's checking the PM timer, and
doesn't seem to touch the TSC, then it marks the TSC unstable
based on the stability of the PM timer. 

The reason that this caught my attention is that it
marks my (AFAIK stable) tsc as unstable when it first 
runs.

Is there something in here that I'm missing?

---
 arch/i386/kernel/tsc.c |   23 +++++------------------
 1 files changed, 5 insertions(+), 18 deletions(-)

Index: linux-2.6.19/arch/i386/kernel/tsc.c
===================================================================
--- linux-2.6.19.orig/arch/i386/kernel/tsc.c
+++ linux-2.6.19/arch/i386/kernel/tsc.c
@@ -402,40 +402,30 @@ static struct dmi_system_id __initdata b
 
 #define TSC_FREQ_CHECK_INTERVAL (10*MSEC_PER_SEC) /* 10sec in MS */
 static struct timer_list verify_tsc_freq_timer;
-static unsigned long pm_multiplier;
 
 /* XXX - Probably should add locking */
 static void verify_tsc_freq(unsigned long unused)
 {
 	static u64 last_tsc;
-	static unsigned long last_jiffies, last_pm;
+	static unsigned long last_jiffies;
 
 	u64 now_tsc, interval_tsc;
-	unsigned long now_jiffies, interval_jiffies, pm, pm_delta;
+	unsigned long now_jiffies, interval_jiffies ;
 
 	if (check_tsc_unstable())
 		return;
 
 	rdtscll(now_tsc);
 	now_jiffies = jiffies;
-	pm = acpi_pm_read_early();
 
 	if (!last_jiffies)
 		goto out;
 
 	interval_jiffies = now_jiffies - last_jiffies;
 
-	if (pm == last_pm) {
-		interval_tsc = now_tsc - last_tsc;
-		interval_tsc *= HZ;
-		do_div(interval_tsc, cpu_khz*1000);
-	} else {
-		if (pm < last_pm)
-			pm += ACPI_PM_OVRRUN;
-		pm_delta = pm - last_pm;
-		interval_tsc = (((u64) pm_delta) * pm_multiplier) >> 22;
-		do_div(interval_tsc, TICK_NSEC);
-	}
+	interval_tsc = now_tsc - last_tsc;
+	interval_tsc *= HZ;
+	do_div(interval_tsc, cpu_khz*1000);
 
 	if (interval_tsc < (interval_jiffies * 3 / 4)) {
 		printk("TSC appears to be running slowly. "
@@ -446,7 +436,6 @@ static void verify_tsc_freq(unsigned lon
 out:
 	last_tsc = now_tsc;
 	last_jiffies = now_jiffies;
-	last_pm = pm;
 	/* set us up to go off on the next interval: */
 	mod_timer(&verify_tsc_freq_timer,
 		jiffies + msecs_to_jiffies(TSC_FREQ_CHECK_INTERVAL));
@@ -500,8 +489,6 @@ static int __init init_tsc_clocksource(v
 		if (!pmtmr_ioport || !clocksource_tsc.rating)
 			clocksource_tsc.is_continuous = 0;
 
-		pm_multiplier = clocksource_hz2mult(PMTMR_TICKS_PER_SEC, 22);
-
 		init_timer(&verify_tsc_freq_timer);
 		verify_tsc_freq_timer.function = verify_tsc_freq;
 		verify_tsc_freq_timer.expires =
--

                 reply	other threads:[~2006-12-06  1:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20061206010604.916239000@mvista.com \
    --to=dwalker@mvista.com \
    --cc=johnstul@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /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