All pastes #981567 Raw Edit

Someone

public diff v1 · immutable
#981567 ·published 2008-04-11 21:51 UTC
rendered paste body
diff -ruN linux-source-2.6.18.orig/arch/um/kernel/time.c linux-source-2.6.18/arch/um/kernel/time.c--- linux-source-2.6.18.orig/arch/um/kernel/time.c	2006-09-19 20:42:06.000000000 -0700+++ linux-source-2.6.18/arch/um/kernel/time.c	2007-12-03 11:06:04.000000000 -0800@@ -18,7 +18,6 @@ #include "asm/param.h" #include "asm/current.h" #include "kern_util.h"-#include "user_util.h" #include "mode.h" #include "os.h" @@ -38,31 +37,31 @@ /* Changed at early boot */ int timer_irq_inited = 0; -static unsigned long long prev_nsecs; #ifdef CONFIG_UML_REAL_TIME_CLOCK-static long long delta;   		/* Deviation per interval */+static unsigned long long prev_nsecs[NR_CPUS];+static long long delta[NR_CPUS];		/* Deviation per interval */ #endif  void timer_irq(union uml_pt_regs *regs) { 	unsigned long long ticks = 0;- #ifdef CONFIG_UML_REAL_TIME_CLOCK-	if(prev_nsecs){+	int c = cpu();+	if(prev_nsecs[c]){ 		/* We've had 1 tick */ 		unsigned long long nsecs = os_nsecs(); -		delta += nsecs - prev_nsecs;-		prev_nsecs = nsecs;+		delta[c] += nsecs - prev_nsecs[c];+		prev_nsecs[c] = nsecs;  		/* Protect against the host clock being set backwards */-		if(delta < 0)-			delta = 0;+		if(delta[c] < 0)+			delta[c] = 0; -		ticks += (delta * HZ) / BILLION;-		delta -= (ticks * BILLION) / HZ;+		ticks += (delta[c] * HZ) / BILLION;+		delta[c] -= (ticks * BILLION) / HZ; 	}-	else prev_nsecs = os_nsecs();+	else prev_nsecs[c] = os_nsecs(); #else 	ticks = 1; #endif@@ -72,8 +71,8 @@ 	} } +/* Protects local_offset */ static DEFINE_SPINLOCK(timer_spinlock);- static unsigned long long local_offset = 0;  static inline unsigned long long get_time(void)@@ -89,16 +88,21 @@ 	return nsecs; } -irqreturn_t um_timer(int irq, void *dev, struct pt_regs *regs)+irqreturn_t um_timer(int irq, void *dev) { 	unsigned long long nsecs; 	unsigned long flags;  	write_seqlock_irqsave(&xtime_lock, flags); -	do_timer(regs);+	do_timer(1); -	nsecs = get_time() + local_offset;+#ifdef CONFIG_UML_REAL_TIME_CLOCK+	nsecs = get_time();+#else+	nsecs = (unsigned long long) xtime.tv_sec * BILLION + xtime.tv_nsec ++		BILLION / HZ;+#endif 	xtime.tv_sec = nsecs / NSEC_PER_SEC; 	xtime.tv_nsec = nsecs - xtime.tv_sec * NSEC_PER_SEC; @@ -113,7 +117,7 @@  	err = request_irq(TIMER_IRQ, um_timer, IRQF_DISABLED, "timer", NULL); 	if(err != 0)-		printk(KERN_ERR "timer_init : request_irq failed - "+		printk(KERN_ERR "register_timer : request_irq failed - " 		       "errno = %d\n", -err);  	timer_irq_inited = 1;@@ -130,13 +134,18 @@ 	nsecs = os_nsecs(); 	set_normalized_timespec(&wall_to_monotonic, -nsecs / BILLION, 				-nsecs % BILLION);+	set_normalized_timespec(&xtime, nsecs / BILLION, nsecs % BILLION); 	late_time_init = register_timer; }  void do_gettimeofday(struct timeval *tv) {+#ifdef CONFIG_UML_REAL_TIME_CLOCK 	unsigned long long nsecs = get_time();-+#else+	unsigned long long nsecs = (unsigned long long) xtime.tv_sec * BILLION ++		xtime.tv_nsec;+#endif 	tv->tv_sec = nsecs / NSEC_PER_SEC; 	/* Careful about calculations here - this was originally done as 	 * (nsecs - tv->tv_sec * NSEC_PER_SEC) / NSEC_PER_USEC@@ -170,6 +179,8 @@  void timer_handler(int sig, union uml_pt_regs *regs) {+	if(current_thread->cpu == 0)+		timer_irq(regs); 	local_irq_disable(); 	irq_enter(); 	update_process_times(CHOOSE_MODE(@@ -177,6 +188,4 @@ 			     (regs)->skas.is_user)); 	irq_exit(); 	local_irq_enable();-	if(current_thread->cpu == 0)-		timer_irq(regs); }