Index: linux-2.6.7/arch/ia64/kernel/time.c
===================================================================
--- linux-2.6.7.orig/arch/ia64/kernel/time.c
+++ linux-2.6.7/arch/ia64/kernel/time.c
@@ -47,6 +47,32 @@
 
 static struct time_interpolator itc_interpolator;
 
+#define FASTCALL_DEBUG
+
+#ifdef FASTCALL_DEBUG
+struct {
+       unsigned long off;
+       unsigned long x1;
+       unsigned long x2;
+       unsigned long x3;
+       unsigned long x4;
+       unsigned long x5;
+       unsigned long x6;
+       unsigned long x7;
+       unsigned long x8;
+       unsigned long x9;
+       unsigned long x10;
+} fastcall_debug;
+#endif
+
+#define COUNTER_DEBUG
+
+#ifdef COUNTER_DEBUG
+unsigned count_gettimeofday,count_einval,count_efault,count_gettimeofday_success;
+unsigned count_gettimeofday_retry,count_clock_gettime,count_clock_gettime_success;
+unsigned count_clock_gettime_retry;
+#endif
+
 int
 do_settimeofday (struct timespec *tv)
 {
@@ -105,6 +131,18 @@
 
 	tv->tv_sec = sec;
 	tv->tv_usec = usec;
+#ifdef FASTCALL_DEBUG
+       if (fastcall_debug.off)
+       {
+               printk("fastcall_debug clock_diff=%lu,nsec_diff=%lu ti_offs=%lu xt.sec=%lu xt.nsec=%lu t.sec=%lu t.nsec=%lu r.usec=%lu x9=%lu\n",
+               fastcall_debug.x1,fastcall_debug.x2,fastcall_debug.x3,fastcall_debug.x4,
+               fastcall_debug.x5,fastcall_debug.x6,fastcall_debug.x7,fastcall_debug.x8,
+               fastcall_debug.x9);
+               printk("c-gettimeofday result sec=%lu nsec=%lu\n",sec,usec);
+               memset(&fastcall_debug,0,sizeof(fastcall_debug));
+       }
+#endif
+
 }
 
 EXPORT_SYMBOL(do_gettimeofday);
Index: linux-2.6.7/arch/ia64/kernel/fsys.S
===================================================================
--- linux-2.6.7.orig/arch/ia64/kernel/fsys.S
+++ linux-2.6.7/arch/ia64/kernel/fsys.S
@@ -145,6 +145,9 @@
 	FSYS_RETURN
 END(fsys_set_tid_address)
 
+#define FASTCALL_DEBUG
+#define COUNTER_DEBUG
+
 ENTRY(fsys_gettimeofday)
 	// Register map
 	// r2,r3 = general short term
@@ -154,6 +157,8 @@
 	// r23 = time interpolator first quad with sourcetype, shift, nsec_per_cyc
 	// r24 = time interpolator_last_counter
 	// r25 = new sequence number
+	// r26 = Pointer to debug information
+	// r27 = pointer to counters
 	// r28 = points to nsec portion of argument (r32+8)
 	// r29 = time interpolator counter address
 	// r30 = time interpolator address
@@ -162,6 +167,12 @@
 	.prologue
 	.altrp b6
 	.body
+#ifdef COUNTER_DEBUG
+	movl r27 = count_gettimeofday ;;
+	ld4 r2 =[r27] ;;
+	add r2 = 1,r2 ;;
+	st4 [r27]=r2;;
+#endif
 	add r2 = TI_FLAGS+IA64_TASK_SIZE,r16
 	tnat.nz p6,p0 = r32               // guard against NaT args
 (p6)    br.cond.spnt.few .fail_einval
@@ -189,6 +200,17 @@
 EX(.fail_efault, probe.w.fault r28, 3)          // this must come _after_ NaT-check
         nop 0
 	;;
+#ifdef FASTCALL_DEBUG
+        movl r26=fastcall_debug
+        ;;
+        ld8 r2=[r26]
+        ;;
+        cmp.ne p6, p0 = r0, r2                  // If debug information has already been written
+(p6)    br.spnt.many fsys_fallback_syscall      // then fall back instead of doing a fastcall
+        ;;
+        st8 [r26]=r26,8
+        ;;
+#endif
 .timeofday_retry:
 	ld8 r23 = [r30],8		// time_interpolator->source/shift/nsec_per_cyc
 	;;
@@ -215,6 +237,10 @@
 	;;
 	sub r2 = r2, r24	// current_counter - last_counter
 	;;
+#ifdef FASTCALL_DEBUG
+	st8 [r26] = r2,8		// clock_diff
+	;;
+#endif
 	setf.sig f8 = r2
 	;;
 	xmpy.l f8 = f8,f7	// nsec_per_cyc*(timeval-last_counter)
@@ -227,14 +253,33 @@
 	add r22 = 8,r21
 	ld8 r3 = [r3]		// time_interpolator_offset
 	;;
+#ifdef FASTCALL_DEBUG
+	st8 [r26] = r2,8		// nsec_diff
+	;;
+	st8 [r26] = r3,8
+#endif
+	;;
  	ld8 r21 = [r21]		// xtime.tv_sec
 	ld8 r22 = [r22]		// xtime_tv_nsec
 	mf
 	add r2 = r2,r3		// Add time interpolator offset
 	ld4 r25 = [r31]		// xtime_lock.sequence
 	;;
+#ifdef FASTCALL_DEBUG
+	st8 [r26] = r21,8		// xtime structure
+	;;
+	st8 [r26] = r22,8
+	;;
+#endif
 	add r22 = r22,r2	// Add xtime.nsecs
 	cmp4.ne p6,p0 = r25,r20
+#ifdef COUNTER_DEBUG
+	;;
+(p6)	movl r27 = count_gettimeofday_retry ;;
+(p6)	ld4 r2 =[r27] ;;
+(p6)	add r2 = 1,r2 ;;
+(p6)	st4 [r27] = r2 ;;
+#endif
 (p6)	br.cond.dpnt .timeofday_retry	// sequence number changed
 	//  now r21=tv->tv_nsec and r22=tv->tv_sec
 	movl r2 = 1000000000
@@ -247,6 +292,12 @@
 (p6)	br.cond.dpnt .timeofday_checkagain
 	;;
 	// now r21,r22 contains the normalized time
+#ifdef FASTCALL_DEBUG
+	st8 [r26] = r21,8
+	;;
+	st8 [r26] = r22,8
+	;;
+#endif
 
 EX(.fail_efault, st8 [r32] = r21)			// tv->tv_sec = seconds
 
@@ -268,15 +319,37 @@
 	;;
 EX(.fail_efault, st8 [r28] = r2)
 
+#ifdef FASTCALL_DEBUG
+	st8 [r26] = r2,8
+	;;
+#endif
+#ifdef COUNTER_DEBUG
+	movl r27 = count_gettimeofday_success ;;
+	ld4 r2 =[r27] ;;
+	add r2 = 1,r2 ;;
+	st4 [r27]=r2;;
+#endif
 	mov r8 = r0
 	mov r10 = r0
 	FSYS_RETURN
 .fail_einval:
+#ifdef COUNTER_DEBUG
+	movl r27 = count_einval	;;
+	ld4 r2 =[r27] ;;
+	add r2 = 1,r2 ;;
+	st4 [r27]=r2;;
+#endif
 	mov r8 = EINVAL			// r8 = EINVAL
 	mov r10 = -1			// r10 = -1
 	FSYS_RETURN
 
 .fail_efault:
+#ifdef COUNTER_DEBUG
+	movl r27 = count_efault	;;
+	ld4 r2 =[r27] ;;
+	add r2 = 1,r2 ;;
+	st4 [r27]=r2 ;;
+#endif
 	mov r8 = EFAULT			// r8 = EFAULT
 	mov r10 = -1			// r10 = -1
 	FSYS_RETURN
@@ -300,6 +373,12 @@
 	.prologue
 	.altrp b6
 	.body
+#ifdef COUNTER_DEBUG
+	movl r27 = count_clock_gettime;;
+	ld4 r2 =[r27];;
+	add r2 = 1,r2;;
+	st4 [r27]=r2;;
+#endif
 	add r2 = TI_FLAGS+IA64_TASK_SIZE,r16
 	movl r30 = time_interpolator
 	;;
@@ -374,6 +453,13 @@
 	ld4 r2 = [r31]		// xtime_lock.sequence
 	;;
 	cmp4.ne p6,p0 = r2,r20
+#ifdef COUNTER_DEBUG
+	;;
+(p6)	movl r27 = count_clock_gettime_retry;;
+(p6)	ld4 r2 =[r27];;
+(p6)	add r2 = 1,r2;;
+(p6)	st4 [r27]=r2;;
+#endif
 (p6)	br.cond.dpnt .gettime_retry
 	//  now r21=tv->tv_nsec and r22=tv->tv_sec
 	movl r2 = 1000000000
@@ -388,6 +474,12 @@
 	// now r21,r22 contain the normalized time
 EX(.fail_efault, st8 [r33] = r21)		// tv->tv_sec = seconds
 EX(.fail_efault, st8 [r28] = r22)			// tv->tv_nsec = nanosecs
+#ifdef COUNTER_DEBUG
+	movl r27 = count_clock_gettime_success;;
+	ld4 r2 =[r27];;
+	add r2 = 1,r2;;
+	st4 [r27]=r2;;
+#endif
 	mov r8 = r0
 	mov r10 = r0
 	FSYS_RETURN
