Re: [PATCH] time: remove xtime_cache (take 2)

Previous thread: [PATCH v3 3/6] RapidIO: Add Port-Write handling for EM by Alexandre Bounine on Tuesday, April 6, 2010 - 2:22 pm. (3 messages)

Next thread: [PATCH] radix_tree_tag_get() is not as safe as the docs make out [ver #2] by David Howells on Tuesday, April 6, 2010 - 2:36 pm. (3 messages)
From: John Stultz
Date: Tuesday, April 6, 2010 - 2:30 pm

Thomas: Mind queueing this up for 2.6.35?

With the earlier logarithmic time accumulation patch, xtime will now
always be within one "tick" of the current time, instead of possibly
half a second off.

This removes the need for the xtime_cache value, which always stored the
time at the last interrupt, so this patch cleans that up removing the
xtime_cache related code.

This patch also addresses an issue with an earlier version of this change,
where xtime_cache was normalizing xtime, which could in some cases be
not valid (ie: tv_nsec == NSEC_PER_SEC). This is fixed by handling
the edge case in update_wall_time().

Cc: Petr Titěra <P.Titera@century.cz>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: John Stultz <johnstul@us.ibm.com>
---
 include/linux/time.h      |    1 -
 kernel/time.c             |    1 -
 kernel/time/timekeeping.c |   35 ++++++++++++++++-------------------
 3 files changed, 16 insertions(+), 21 deletions(-)

diff --git a/include/linux/time.h b/include/linux/time.h
index 6e026e4..ea3559f 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -150,7 +150,6 @@ extern struct timespec timespec_trunc(struct timespec t, unsigned gran);
 extern int timekeeping_valid_for_hres(void);
 extern u64 timekeeping_max_deferment(void);
 extern void update_wall_time(void);
-extern void update_xtime_cache(u64 nsec);
 extern void timekeeping_leap_insert(int leapsecond);
 
 struct tms;
diff --git a/kernel/time.c b/kernel/time.c
index 656dccf..129fe12 100644
--- a/kernel/time.c
+++ b/kernel/time.c
@@ -135,7 +135,6 @@ 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();
 }
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 39f6177..dec9175 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -165,13 +165,6 ...
From: Andrew Morton
Date: Monday, April 12, 2010 - 6:00 pm

This conflicts with your time-clean-up-warp_clock.patch, below.

Shrug, I simply ignored the rejected hunk.



From: John Stultz <johnstul@us.ibm.com>

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

Signed-off-by: John Stultz <johnstul@us.ibm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 kernel/time.c |   11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff -puN kernel/time.c~time-clean-up-warp_clock kernel/time.c
--- a/kernel/time.c~time-clean-up-warp_clock
+++ a/kernel/time.c
@@ -132,12 +132,11 @@ SYSCALL_DEFINE2(gettimeofday, struct tim
  */
 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);
 }
 
 /*
_

--

From: john stultz
Date: Monday, April 12, 2010 - 9:06 pm

Yep. That should be fine. We're just dropping the update_xtime_cache
call, so if it doesn't exist, its not a problem.

thanks
-john

--

Previous thread: [PATCH v3 3/6] RapidIO: Add Port-Write handling for EM by Alexandre Bounine on Tuesday, April 6, 2010 - 2:22 pm. (3 messages)

Next thread: [PATCH] radix_tree_tag_get() is not as safe as the docs make out [ver #2] by David Howells on Tuesday, April 6, 2010 - 2:36 pm. (3 messages)