public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] - sched_clock() broken for ia64 SN platform
@ 2003-11-20  0:56 John Hawkes
  2003-11-20  1:24 ` David Mosberger
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: John Hawkes @ 2003-11-20  0:56 UTC (permalink / raw)
  To: linux-ia64

sched_clock() is broken in 2.6.0-test9 for ia64 "drifty ITC" platforms,
such as the SGI "SN" platform.  The CPU Scheduler expects sched_clock() to
return a nanosecond value that is synchronized across all CPUs, and the SN
platform must use platform's RealTimeClock (RTC).

I attach a patch that fixes this for the SN platform.

We might instead want to implement a more general scheme, along the lines of
what is done by (struct time_interpolator), to provide a framework to solve
this for other architectures that have "drifty" non-default timebases.

John Hawkes


diff -X /home/hawkes/Patches/ignore.dirs -Naur linux-2.6.0/arch/ia64/kernel/time.c linux-2.6.0-schedclock/arch/ia64/kernel/time.c
--- linux-2.6.0/arch/ia64/kernel/time.c	Mon Oct 20 12:48:11 2003
+++ linux-2.6.0-schedclock/arch/ia64/kernel/time.c	Tue Nov 18 17:28:31 2003
@@ -42,12 +42,18 @@
 
 #endif
 
+static unsigned long long
+itc_sched_clock (void)
+{
+	return jiffies * (1000000000/HZ);	/* a crude-granularity hack */
+}
+
+unsigned long long (*ia64_sched_clock)(void) = &itc_sched_clock;
+
 unsigned long long
 sched_clock (void)
 {
-	unsigned long offset = ia64_get_itc();
-
-	return (offset * local_cpu_data->nsec_per_cyc) >> IA64_NSEC_PER_CYC_SHIFT;
+	return ia64_sched_clock();
 }
 
 static void
diff -X /home/hawkes/Patches/ignore.dirs -Naur linux-2.6.0/arch/ia64/sn/kernel/sn2/timer.c linux-2.6.0-schedclock/arch/ia64/sn/kernel/sn2/timer.c
--- linux-2.6.0/arch/ia64/sn/kernel/sn2/timer.c	Mon Jul 14 11:51:29 2003
+++ linux-2.6.0-schedclock/arch/ia64/sn/kernel/sn2/timer.c	Wed Nov 19 10:00:43 2003
@@ -22,6 +22,8 @@
 extern unsigned long sn_rtc_cycles_per_second;
 static volatile unsigned long last_wall_rtc;
 
+extern unsigned long long (*ia64_sched_clock)(void);
+
 static unsigned long rtc_offset;	/* updated only when xtime write-lock is held! */
 static long rtc_nsecs_per_cycle;
 static long rtc_per_timer_tick;
@@ -55,6 +57,12 @@
 	last_wall_rtc = GET_RTC_COUNTER();
 }
 
+static unsigned long long
+sn_sched_clock(void)
+{
+	return GET_RTC_COUNTER() * rtc_nsecs_per_cycle;
+}
+
 
 static struct time_interpolator sn2_interpolator = {
 	.get_offset =	getoffset,
@@ -73,4 +81,6 @@
 	rtc_nsecs_per_cycle = 1000000000 / sn_rtc_cycles_per_second;
 
 	last_wall_rtc = GET_RTC_COUNTER();
+
+	ia64_sched_clock = &sn_sched_clock;
 }

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2003-11-20 22:14 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-11-20  0:56 [PATCH] - sched_clock() broken for ia64 SN platform John Hawkes
2003-11-20  1:24 ` David Mosberger
2003-11-20  4:09 ` John Hawkes
2003-11-20  6:01 ` David Mosberger
2003-11-20 15:23 ` Jack Steiner
2003-11-20 17:25 ` Grant Grundler
2003-11-20 17:25 ` Rich Altmaier
2003-11-20 18:32 ` David Mosberger
2003-11-20 19:20 ` Robin Holt
2003-11-20 19:23 ` Robin Holt
2003-11-20 20:58 ` John Hawkes
2003-11-20 21:27 ` David Mosberger
2003-11-20 21:58 ` john stultz
2003-11-20 22:14 ` John Hawkes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox