aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/time/timekeeping.c
diff options
context:
space:
mode:
authorMartin Schwidefsky <schwidefsky@de.ibm.com>2009-08-14 15:47:30 +0200
committerThomas Gleixner <tglx@linutronix.de>2009-08-15 10:55:46 +0200
commit75c5158f70c065b9704b924503d96e8297838f79 (patch)
tree74b02ba1f13aaf8292bd472a8a197ac900ff20e7 /kernel/time/timekeeping.c
parent2ba2a3054fdffc8e6452f4ee120760322a6fbd43 (diff)
downloadkernel_samsung_crespo-75c5158f70c065b9704b924503d96e8297838f79.zip
kernel_samsung_crespo-75c5158f70c065b9704b924503d96e8297838f79.tar.gz
kernel_samsung_crespo-75c5158f70c065b9704b924503d96e8297838f79.tar.bz2
timekeeping: Update clocksource with stop_machine
update_wall_time calls change_clocksource HZ times per second to check if a new clock source is available. In close to 100% of all calls there is no new clock. Replace the tick based check by an update done with stop_machine. Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Ingo Molnar <mingo@elte.hu> Acked-by: John Stultz <johnstul@us.ibm.com> Cc: Daniel Walker <dwalker@fifo99.com> LKML-Reference: <20090814134810.711836357@de.ibm.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/time/timekeeping.c')
-rw-r--r--kernel/time/timekeeping.c41
1 files changed, 26 insertions, 15 deletions
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 27ae01b..41579e7 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -18,6 +18,7 @@
#include <linux/jiffies.h>
#include <linux/time.h>
#include <linux/tick.h>
+#include <linux/stop_machine.h>
/* Structure holding internal timekeeping values. */
struct timekeeper {
@@ -179,6 +180,7 @@ void timekeeping_leap_insert(int leapsecond)
}
#ifdef CONFIG_GENERIC_TIME
+
/**
* timekeeping_forward_now - update clock to the current time
*
@@ -351,31 +353,40 @@ EXPORT_SYMBOL(do_settimeofday);
*
* Accumulates current time interval and initializes new clocksource
*/
-static void change_clocksource(void)
+static int change_clocksource(void *data)
{
struct clocksource *new, *old;
- new = clocksource_get_next();
-
- if (!new || timekeeper.clock == new)
- return;
+ new = (struct clocksource *) data;
timekeeping_forward_now();
+ if (!new->enable || new->enable(new) == 0) {
+ old = timekeeper.clock;
+ timekeeper_setup_internals(new);
+ if (old->disable)
+ old->disable(old);
+ }
+ return 0;
+}
- if (new->enable && !new->enable(new))
+/**
+ * timekeeping_notify - Install a new clock source
+ * @clock: pointer to the clock source
+ *
+ * This function is called from clocksource.c after a new, better clock
+ * source has been registered. The caller holds the clocksource_mutex.
+ */
+void timekeeping_notify(struct clocksource *clock)
+{
+ if (timekeeper.clock == clock)
return;
-
- old = timekeeper.clock;
- timekeeper_setup_internals(new);
-
- if (old->disable)
- old->disable(old);
-
+ stop_machine(change_clocksource, clock, NULL);
tick_clock_notify();
}
+
#else /* GENERIC_TIME */
+
static inline void timekeeping_forward_now(void) { }
-static inline void change_clocksource(void) { }
/**
* ktime_get - get the monotonic time in ktime_t format
@@ -416,6 +427,7 @@ void ktime_get_ts(struct timespec *ts)
ts->tv_nsec + tomono.tv_nsec);
}
EXPORT_SYMBOL_GPL(ktime_get_ts);
+
#endif /* !GENERIC_TIME */
/**
@@ -773,7 +785,6 @@ void update_wall_time(void)
update_xtime_cache(nsecs);
/* check to see if there is a new clocksource to use */
- change_clocksource();
update_vsyscall(&xtime, timekeeper.clock);
}