Skip to contentSkip to conversation

Fix oops on !GENERIC_TIME systems when accessing current_clocksource

PATCH RESEND In review john stultz 2 participants 4 messages Mar 1, 2010 – Mar 8, 2010 Timekeeping, clocksource core, NTP, alarmtimer

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 Fix oops on !GENERIC_TIME systems when accessing current_clocksource

No one has replied to this, so I wanted to send it out again.

Aaro Koskinen reported an issue in bug #15366, where on non-GENERIC_TIME
systems,
accessing /sys/devices/system/clocksource/clocksource0/current_clocksource would oops the system.

It seems the timekeeper/clocksource rework missed initializing the curr_clocksource value in the !GENERIC_TIME.

The following patch makes sure it gets initialized, and avoids the issue.

Thanks to Aaro for reporting and diagnosing the issue as well as testing the fix!

Bug Details: http://bugzilla.kernel.org/show_bug.cgi?id=15366

Too late for 2.6.33, but this likely should go into 2.6.33-stable and 2.6.32-stable.

thanks
-john

kernel/time/clocksource.c +4 -0
index e85c234..c436ee5 100644
@@ -568,6 +568,10 @@ static inline void clocksource_select(void) { }
  */
 static int __init clocksource_done_booting(void)
 {
+	mutex_lock(&clocksource_mutex);
+	curr_clocksource = clocksource_default_clock();
+	mutex_unlock(&clocksource_mutex);
+
 	finished_booting = 1;
 
 	/*
#1 lore raw

[tip:timers/urgent] timekeeping: Prevent oops when GENERIC_TIME=n

Commit-ID:  ad6759fbf35d104dbf573cd6f4c6784ad6823f7e
Gitweb:     http://git.kernel.org/tip/ad6759fbf35d104dbf573cd6f4c6784ad6823f7e
Author:     john stultz <[email protected]>
AuthorDate: Mon, 1 Mar 2010 12:34:43 -0800
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 2 Mar 2010 09:22:25 +0100

timekeeping: Prevent oops when GENERIC_TIME=n

Aaro Koskinen reported an issue in kernel.org bugzilla #15366, where on non-GENERIC_TIME systems, accessing /sys/devices/system/clocksource/clocksource0/current_clocksource results in an oops.

It seems the timekeeper/clocksource rework missed initializing the curr_clocksource value in the !GENERIC_TIME case.

Thanks to Aaro for reporting and diagnosing the issue as well as testing the fix!

LKML-Reference: <[email protected]>

---
 kernel/time/clocksource.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
kernel/time/clocksource.c +4 -0
index 1f663d2..1f5dde6 100644
@@ -592,6 +592,10 @@ static inline void clocksource_select(void) { }
  */
 static int __init clocksource_done_booting(void)
 {
+	mutex_lock(&clocksource_mutex);
+	curr_clocksource = clocksource_default_clock();
+	mutex_unlock(&clocksource_mutex);
+
 	finished_booting = 1;
 
 	/*
#2 lore raw
In reply to john stultz
Quoted 1 line · john stultz

No one has replied to this, so I wanted to send it out again.

Just another ping here. I know the patch has made it to -tip, but its something that should be needed for 2.6.34, 2.6.33-stable.

thanks
-john

Quoted 41 lines

Aaro Koskinen reported an issue in bug #15366, where on non-GENERIC_TIME
systems,
accessing /sys/devices/system/clocksource/clocksource0/current_clocksource would oops the system.

It seems the timekeeper/clocksource rework missed initializing the curr_clocksource value in the !GENERIC_TIME.

The following patch makes sure it gets initialized, and avoids the issue.

Thanks to Aaro for reporting and diagnosing the issue as well as testing the fix!

Bug Details: http://bugzilla.kernel.org/show_bug.cgi?id=15366

Too late for 2.6.33, but this likely should go into 2.6.33-stable and 2.6.32-stable.

thanks
-john

kernel/time/clocksource.c +4 -0
index e85c234..c436ee5 100644
@@ -568,6 +568,10 @@ static inline void clocksource_select(void) { }
  */
 static int __init clocksource_done_booting(void)
 {
+	mutex_lock(&clocksource_mutex);
+	curr_clocksource = clocksource_default_clock();
+	mutex_unlock(&clocksource_mutex);
+
 	finished_booting = 1;
 
 	/*
#3 lore raw
Quoted 5 lines · john stultz
Quoted 1 line · john stultz

No one has replied to this, so I wanted to send it out again.

Just another ping here. I know the patch has made it to -tip, but its something that should be needed for 2.6.34, 2.6.33-stable.

I'm going to send a pull request tomorrow.

Thanks,

tglx