Skip to contentSkip to conversation

clocksource: save mult_orig in clocksource_disable()

PATCH In review Magnus Damm 3 participants 9 messages Jun 18, 2009 – Jul 31, 2009 Timekeeping, clocksource core, NTP, alarmtimer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clocksource: save mult_orig in clocksource_disable()

From: Magnus Damm <[email protected]>

Save clocksource mult_orig in clocksource_disable().

To fix the common case where ->enable() does not setup mult, make sure mult_orig is saved in mult on disable.

Also add comments to explain why we do this.

---

 include/linux/clocksource.h |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
include/linux/clocksource.h +11 -1
@@ -293,7 +293,11 @@ static inline int clocksource_enable(str
 	if (cs->enable)
 		ret = cs->enable(cs);
 
-	/* save mult_orig on enable */
+	/* The frequency may have changed while the clocksource
+	 * was disabled. If so the code in ->enable() must update
+	 * the mult value to reflect the new frequency. Make sure
+	 * mult_orig follows this change.
+	 */
 	cs->mult_orig = cs->mult;
 
 	return ret;
@@ -309,6 +313,12 @@ static inline int clocksource_enable(str
  */
 static inline void clocksource_disable(struct clocksource *cs)
 {
+	/* Save mult_orig in mult so clocksource_enable() can
+	 * restore the value regardless if ->enable() updates
+	 * the value of mult or not.
+	 */
+	cs->mult = cs->mult_orig;
+
 	if (cs->disable)
 		cs->disable(cs);
 }
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Magnus Damm

From: Magnus Damm <[email protected]>

Save clocksource mult_orig in clocksource_disable().

To fix the common case where ->enable() does not setup mult, make sure mult_orig is saved in mult on disable.

Also add comments to explain why we do this.

Thomas, Andrew, please push this for 2.6.31.

thanks
-john

Quoted 33 lines

---

 include/linux/clocksource.h |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
include/linux/clocksource.h +11 -1
@@ -293,7 +293,11 @@ static inline int clocksource_enable(str
 	if (cs->enable)
 		ret = cs->enable(cs);
 
-	/* save mult_orig on enable */
+	/* The frequency may have changed while the clocksource
+	 * was disabled. If so the code in ->enable() must update
+	 * the mult value to reflect the new frequency. Make sure
+	 * mult_orig follows this change.
+	 */
 	cs->mult_orig = cs->mult;
 
 	return ret;
@@ -309,6 +313,12 @@ static inline int clocksource_enable(str
  */
 static inline void clocksource_disable(struct clocksource *cs)
 {
+	/* Save mult_orig in mult so clocksource_enable() can
+	 * restore the value regardless if ->enable() updates
+	 * the value of mult or not.
+	 */
+	cs->mult = cs->mult_orig;
+
 	if (cs->disable)
 		cs->disable(cs);
 }
#2 lore raw
Quoted 8 lines · john stultz
Quoted 7 lines · Magnus Damm

From: Magnus Damm <[email protected]>

Save clocksource mult_orig in clocksource_disable().

To fix the common case where ->enable() does not setup mult, make sure mult_orig is saved in mult on disable.

Quoted 7 lines
Quoted 3 lines

Also add comments to explain why we do this.

Thomas, Andrew, please push this for 2.6.31.

This one is slowly making it's way in I suppose?

/ magnus

#3 lore raw
Quoted 11 lines · Magnus Damm
Quoted 10 lines · john stultz
Quoted 9 lines · Magnus Damm

From: Magnus Damm <[email protected]>

Save clocksource mult_orig in clocksource_disable().

To fix the common case where ->enable() does not setup mult, make sure mult_orig is saved in mult on disable.

Also add comments to explain why we do this.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Thomas, Andrew, please push this for 2.6.31.

This one is slowly making it's way in I suppose?

Btw., what specific issue does this fix? The commit description is generic, there's no bugzilla link and no other information either that could give me an idea about precisely what incarnation of the bug you have hit.

Thanks,

Ingo

#4 lore raw
Quoted 18 lines · Ingo Molnar
Quoted 15 lines · Magnus Damm
Quoted 14 lines · john stultz
Quoted 10 lines · Magnus Damm

From: Magnus Damm <[email protected]>

Save clocksource mult_orig in clocksource_disable().

To fix the common case where ->enable() does not setup mult, make sure mult_orig is saved in mult on disable.

Also add comments to explain why we do this.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Thomas, Andrew, please push this for 2.6.31.

This one is slowly making it's way in I suppose?

Btw., what specific issue does this fix? The commit description is generic, there's no bugzilla link and no other information either that could give me an idea about precisely what incarnation of the bug you have hit.

The comments in the actual code gives more details, but that's probably not where you want this to be explained. I can resend a version with more verbose commit message early next week if you'd like. Please let me know if so.

I'm not aware of any bugzilla links, maybe John knows?

Cheers,

/ magnus

#5 lore raw
Quoted 28 lines · Magnus Damm
Quoted 18 lines · Ingo Molnar
Quoted 15 lines · Magnus Damm
Quoted 14 lines · john stultz
Quoted 10 lines · Magnus Damm

From: Magnus Damm <[email protected]>

Save clocksource mult_orig in clocksource_disable().

To fix the common case where ->enable() does not setup mult, make sure mult_orig is saved in mult on disable.

Also add comments to explain why we do this.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Thomas, Andrew, please push this for 2.6.31.

This one is slowly making it's way in I suppose?

Btw., what specific issue does this fix? The commit description is generic, there's no bugzilla link and no other information either that could give me an idea about precisely what incarnation of the bug you have hit.

Quoted 6 lines

The comments in the actual code gives more details, but that's probably not where you want this to be explained. I can resend a version with more verbose commit message early next week if you'd like. Please let me know if so.

I'm not aware of any bugzilla links, maybe John knows?

No bugzilla link. I found this while reviewing the patch, however at that point it had already been pulled into -tip and my objections somehow never made it to anyone's eyes before it got pulled into mainline.

thanks
-john

#6 lore raw
In reply to Ingo Molnar
Quoted 17 lines · Ingo Molnar
Quoted 15 lines · Magnus Damm
Quoted 14 lines · john stultz
Quoted 10 lines · Magnus Damm

From: Magnus Damm <[email protected]>

Save clocksource mult_orig in clocksource_disable().

To fix the common case where ->enable() does not setup mult, make sure mult_orig is saved in mult on disable.

Also add comments to explain why we do this.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Thomas, Andrew, please push this for 2.6.31.

This one is slowly making it's way in I suppose?

Btw., what specific issue does this fix? The commit description is generic, there's no bugzilla link and no other information either that could give me an idea about precisely what incarnation of the bug you have hit.

Magnus' earlier change to mult_orig makes it so mult_orig is written on enable, instead of when we register the clocksource. This causes problems as enable() might be called multiple times while a system is running, where as the register would only happen once.

If a user switches away from a clocksource and back to a clocksource, the mult_orig will no longer be the original mult, as we will over write it with an NTP adjusted mult.

Its a minor detail, but it causes problems when I do NTP testing across different clocksources, as the ppm drift factor does not stay constant per clocksource.

This fix makes sure we store mult_orig over mult on disable() so we restore the correct value on the next enable().

thanks
-john

#7 lore raw
In reply to Magnus Damm
Commit-ID:  a52c77102626951144165c53a6b54f1e812360d5
Gitweb:     http://git.kernel.org/tip/a52c77102626951144165c53a6b54f1e812360d5
Author:     Magnus Damm <[email protected]>
AuthorDate: Tue, 28 Jul 2009 14:09:55 -0700
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Thu, 30 Jul 2009 21:55:47 +0200

clocksource: save mult_orig in clocksource_disable()

Save clocksource mult_orig in clocksource_disable().

To fix the common case where ->enable() does not setup mult, make sure mult_orig is saved in mult on disable.

Also add comments to explain why we do this.

LKML-Reference: <[email protected]>

---
 include/linux/clocksource.h |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
include/linux/clocksource.h +11 -1
index c56457c..aff9f01 100644
@@ -293,7 +293,11 @@ static inline int clocksource_enable(struct clocksource *cs)
 	if (cs->enable)
 		ret = cs->enable(cs);
 
-	/* save mult_orig on enable */
+	/* The frequency may have changed while the clocksource
+	 * was disabled. If so the code in ->enable() must update
+	 * the mult value to reflect the new frequency. Make sure
+	 * mult_orig follows this change.
+	 */
 	cs->mult_orig = cs->mult;
 
 	return ret;
@@ -309,6 +313,12 @@ static inline int clocksource_enable(struct clocksource *cs)
  */
 static inline void clocksource_disable(struct clocksource *cs)
 {
+	/* Save mult_orig in mult so clocksource_enable() can
+	 * restore the value regardless if ->enable() updates
+	 * the value of mult or not.
+	 */
+	cs->mult = cs->mult_orig;
+
 	if (cs->disable)
 		cs->disable(cs);
 }
#8 lore raw

[tip:timers/urgent] clocksource: Save mult_orig in clocksource_disable()

In reply to Magnus Damm
Commit-ID:  c7121843685de2bf7f3afd3ae1d6a146010bf1fc
Gitweb:     http://git.kernel.org/tip/c7121843685de2bf7f3afd3ae1d6a146010bf1fc
Author:     Magnus Damm <[email protected]>
AuthorDate: Tue, 28 Jul 2009 14:09:55 -0700
Committer:  Ingo Molnar <[email protected]>
CommitDate: Fri, 31 Jul 2009 14:12:36 +0200

clocksource: Save mult_orig in clocksource_disable()

To fix the common case where ->enable() does not set up mult, make sure mult_orig is saved in mult on disable.

Also add comments to explain why we do this.

LKML-Reference: <[email protected]>

---
 include/linux/clocksource.h |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
include/linux/clocksource.h +13 -1
index c56457c..1219be4 100644
@@ -293,7 +293,12 @@ static inline int clocksource_enable(struct clocksource *cs)
 	if (cs->enable)
 		ret = cs->enable(cs);
 
-	/* save mult_orig on enable */
+	/*
+	 * The frequency may have changed while the clocksource
+	 * was disabled. If so the code in ->enable() must update
+	 * the mult value to reflect the new frequency. Make sure
+	 * mult_orig follows this change.
+	 */
 	cs->mult_orig = cs->mult;
 
 	return ret;
@@ -309,6 +314,13 @@ static inline int clocksource_enable(struct clocksource *cs)
  */
 static inline void clocksource_disable(struct clocksource *cs)
 {
+	/*
+	 * Save mult_orig in mult so clocksource_enable() can
+	 * restore the value regardless if ->enable() updates
+	 * the value of mult or not.
+	 */
+	cs->mult = cs->mult_orig;
+
 	if (cs->disable)
 		cs->disable(cs);
 }