[PATCH] Let any CPU update xtime/jiffies

Srivatsa Vaddagiri vatsa at in.ibm.com
Thu Oct 6 03:52:44 EST 2005


Currently, only boot CPU updates xtime/jiffies _and_ invokes
ppc_adjtimex during decrementer interrupt. This makes it difficult for the 
boot cpu to skip ticks when idle.

Following patch changes that behavior so that any CPU can now
update xtime/jiffies. 

Notes: 

- This was tested against 2.6.14-rc1 on a 4way Power4 (p630) box
  alongwith the NO_IDLE_HZ patch.

- This patch does not serialize ppc_adjtimex. Do we need a spinlock
  to serialize it?

Signed-off-by : Srivatsa Vaddagiri <vatsa at in.ibm.com>

---

 linux-2.6.14-rc1-root/arch/ppc64/kernel/time.c |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)

diff -puN arch/ppc64/kernel/time.c~boot_cpu_fix arch/ppc64/kernel/time.c
--- linux-2.6.14-rc1/arch/ppc64/kernel/time.c~boot_cpu_fix	2005-10-05 15:12:37.000000000 +0530
+++ linux-2.6.14-rc1-root/arch/ppc64/kernel/time.c	2005-10-05 16:37:16.000000000 +0530
@@ -342,21 +342,21 @@ int timer_interrupt(struct pt_regs * reg
 		 */
 		if (!cpu_is_offline(cpu))
 			update_process_times(user_mode(regs));
-		/*
-		 * No need to check whether cpu is offline here; boot_cpuid
-		 * should have been fixed up by now.
-		 */
-		if (cpu == boot_cpuid) {
-			write_seqlock(&xtime_lock);
-			tb_last_stamp = lpaca->next_jiffy_update_tb;
-			timer_recalc_offset(lpaca->next_jiffy_update_tb);
+
+		write_seqlock(&xtime_lock);
+		cur_tb = get_tb();
+		if (cur_tb - tb_last_stamp > tb_ticks_per_jiffy) {
+			tb_last_stamp += tb_ticks_per_jiffy;
+			timer_recalc_offset(cur_tb);
 			do_timer(regs);
-			timer_sync_xtime(lpaca->next_jiffy_update_tb);
+			timer_sync_xtime(cur_tb);
 			timer_check_rtc();
-			write_sequnlock(&xtime_lock);
-			if ( adjusting_time && (time_adjust == 0) )
-				ppc_adjtimex();
 		}
+		write_sequnlock(&xtime_lock);
+		/* Fixme: This needs to be serialized as well */
+		if ( adjusting_time && (time_adjust == 0) )
+			ppc_adjtimex();
+
 		lpaca->next_jiffy_update_tb += tb_ticks_per_jiffy;
 	}
 	

_
-- 


Thanks and Regards,
Srivatsa Vaddagiri,
Linux Technology Center,
IBM Software Labs,
Bangalore, INDIA - 560017



More information about the Linuxppc64-dev mailing list