Skip to contentSkip to conversation

time: Cleanup warp_clock

PATCH New John Stultz 2 participants 4 messages Mar 4, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 time: Cleanup warp_clock

Not critical, 2.6.35 material.

warp_clock() currently accesses timekeeping internal state directly, which is unnecessary. Convert it to use the proper timekeeping interfaces.

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Andrew Morton <[email protected]>
---
 kernel/time.c |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)
kernel/time.c +5 -6
index 8047980..abe1c1b 100644
@@ -133,12 +133,11 @@ SYSCALL_DEFINE2(gettimeofday, struct timeval __user *, tv,
  */
 static inline void warp_clock(void)
 {
-	write_seqlock_irq(&xtime_lock);
-	wall_to_monotonic.tv_sec -= sys_tz.tz_minuteswest * 60;
-	xtime.tv_sec += sys_tz.tz_minuteswest * 60;
-	update_xtime_cache(0);
-	write_sequnlock_irq(&xtime_lock);
-	clock_was_set();
+	struct timespec delta, adjust;
+	delta.tv_sec = sys_tz.tz_minuteswest * 60;
+	delta.tv_nsec = 0;
+	adjust = timespec_add_safe(current_kernel_time(), delta);	
+	do_settimeofday(&adjust);
 }
 
 /*
Signature · 1 line
1.6.0.4
#1 lore raw

PATCH 1/1 time: Cleanup direct xtime usage in xen

Not critical, 2.6.35 material.

Cleanup xen's direct use of internal timekeeping values.

Cc Jeremy Fitzhardinge <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Andrew Morton <[email protected]>
---
 arch/x86/xen/time.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/xen/time.c +3 -3
index 0d3f07c..6365df9 100644
@@ -475,6 +475,7 @@ void xen_timer_resume(void)
 __init void xen_time_init(void)
 {
 	int cpu = smp_processor_id();
+	struct timespec tp;
 
 	clocksource_register(&xen_clocksource);
 
@@ -486,9 +487,8 @@ __init void xen_time_init(void)
 	}
 
 	/* Set initial system time with full resolution */
-	xen_read_wallclock(&xtime);
-	set_normalized_timespec(&wall_to_monotonic,
-				-xtime.tv_sec, -xtime.tv_nsec);
+	xen_read_wallclock(&tp);
+	do_settimeofday(&tp);
 
 	setup_force_cpu_cap(X86_FEATURE_TSC);
 
Signature · 1 line
1.6.0.4
#2 lore raw

PATCH 1/1 xtensa: Fix unnecessary setting of xtime

Not critical, 2.6.35 material.

xtensa supports read_persisitent_clock(), so there is no reason for the arch specific code to be setting xtime. Setting xtime will be done by the generic timekeeping code.

Please let me know if this is some sort of a workaround for an issue instead of just an oversight.

Cc Thomas Gleixner <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Chris Zankel <[email protected]>
---
 arch/xtensa/kernel/time.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)
arch/xtensa/kernel/time.c +0 -5
index 19f7df3..19df764 100644
@@ -60,11 +60,6 @@ static struct irqaction timer_irqaction = {
 
 void __init time_init(void)
 {
-	/* FIXME: xtime&wall_to_monotonic are set in timekeeping_init. */
-	read_persistent_clock(&xtime);
-	set_normalized_timespec(&wall_to_monotonic,
-		-xtime.tv_sec, -xtime.tv_nsec);
-
 #ifdef CONFIG_XTENSA_CALIBRATE_CCOUNT
 	printk("Calibrating CPU frequency ");
 	platform_calibrate_ccount();
Signature · 1 line
1.6.0.4
Acked-by on v1 1/1
#3 lore raw

Re: [PATCH] time: Cleanup direct xtime usage in xen

In reply to John Stultz
Quoted 9 lines · John Stultz

Not critical, 2.6.35 material.

Cleanup xen's direct use of internal timekeeping values.

Cc Jeremy Fitzhardinge<[email protected]>
Cc Thomas Gleixner<[email protected]>
Cc Andrew Morton<[email protected]>
Quoted 29 lines
---
  arch/x86/xen/time.c |    6 +++---
  1 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/xen/time.c +3 -3
index 0d3f07c..6365df9 100644
@@ -475,6 +475,7 @@ void xen_timer_resume(void)
  __init void xen_time_init(void)
  {
  	int cpu = smp_processor_id();
+	struct timespec tp;
 
  	clocksource_register(&xen_clocksource);
 
@@ -486,9 +487,8 @@ __init void xen_time_init(void)
  	}
 
  	/* Set initial system time with full resolution */
-	xen_read_wallclock(&xtime);
-	set_normalized_timespec(&wall_to_monotonic,
-				-xtime.tv_sec, -xtime.tv_nsec);
+	xen_read_wallclock(&tp);
+	do_settimeofday(&tp);
 
  	setup_force_cpu_cap(X86_FEATURE_TSC);