[PATCH 1/3] timekeeping: moving xtime's init to a later time

From: Feng Tang
Date: Wed May 19 2010 - 04:57:20 EST


xtime doesn't need to be inited early, move it to a subsys_initcall,
as most of its consumers come from userspace. It will also give enough
time for some MMIO based wallclock devices to init

Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: John Stultz <johnstul@xxxxxxxxxx>
Signed-off-by: Feng Tang <feng.tang@xxxxxxxxx>
---
kernel/time/timekeeping.c | 28 +++++++++++++++++++++-------
1 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 39f6177..7bc32de 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -529,26 +529,37 @@ void __attribute__((weak)) read_boot_clock(struct timespec *ts)
}

/*
- * timekeeping_init - Initializes the clocksource and common timekeeping values
+ * timekeeping_init - Initializes the clocksource
*/
void __init timekeeping_init(void)
{
struct clocksource *clock;
unsigned long flags;
- struct timespec now, boot;
-
- read_persistent_clock(&now);
- read_boot_clock(&boot);

write_seqlock_irqsave(&xtime_lock, flags);

- ntp_init();
-
clock = clocksource_default_clock();
if (clock->enable)
clock->enable(clock);
timekeeper_setup_internals(clock);

+ ntp_init();
+ write_sequnlock_irqrestore(&xtime_lock, flags);
+}
+
+/*
+ * timekeeping_late_init - Initaizes the common timekeeping values
+ */
+static int __init timekeeping_late_init(void)
+{
+ unsigned long flags;
+ struct timespec now, boot;
+
+ read_persistent_clock(&now);
+ read_boot_clock(&boot);
+
+ write_seqlock_irqsave(&xtime_lock, flags);
+
xtime.tv_sec = now.tv_sec;
xtime.tv_nsec = now.tv_nsec;
raw_time.tv_sec = 0;
@@ -563,7 +574,10 @@ void __init timekeeping_init(void)
total_sleep_time.tv_sec = 0;
total_sleep_time.tv_nsec = 0;
write_sequnlock_irqrestore(&xtime_lock, flags);
+
+ return 0;
}
+subsys_initcall(timekeeping_late_init);

/* time in seconds when suspend began */
static struct timespec timekeeping_suspend_time;
--
1.6.3.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/