Skip to contentSkip to conversation

timekeeping fix mismerge

PATCH In review Thomas Gleixner 3 participants 5 messages May 14, 2007 Timekeeping, clocksource core, NTP, alarmtimer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 timekeeping fix mismerge

The time keeping code move to kernel/time/timekeeping.c broke the clocksource resume logic patch. Fix it up and move the clocksource_resume() call to the appropriate place.

kernel/time/clocksource.c +0 -0
kernel/time/timekeeping.c +2 -0
index f9217bf..3d1042f 100644
@@ -273,6 +273,8 @@ static int timekeeping_resume(struct sys_device *dev)
 	unsigned long flags;
 	unsigned long now = read_persistent_clock();
 
+	clocksource_resume();
+
 	write_seqlock_irqsave(&xtime_lock, flags);
 
 	if (now && (now > timekeeping_suspend_time)) {
kernel/timer.c +0 -2
index a6c580a..5ec5490 100644
@@ -1499,8 +1499,6 @@ unregister_time_interpolator(struct time_interpolator *ti)
 		prev = &curr->next;
 	}
 
-	clocksource_resume();
-
 	write_seqlock_irqsave(&xtime_lock, flags);
 	if (ti == time_interpolator) {
 		/* we lost the best time-interpolator: */
#1 lore raw
Quoted 26 lines · On Mon, 14 May 2007 11:10:02 +0200 Thomas Gleixner <[email protected]> wrote:

The time keeping code move to kernel/time/timekeeping.c broke the clocksource resume logic patch. Fix it up and move the clocksource_resume() call to the appropriate place.

kernel/time/clocksource.c +0 -0
kernel/time/timekeeping.c +2 -0
index f9217bf..3d1042f 100644
@@ -273,6 +273,8 @@ static int timekeeping_resume(struct sys_device *dev)
 	unsigned long flags;
 	unsigned long now = read_persistent_clock();
 
+	clocksource_resume();
+
 	write_seqlock_irqsave(&xtime_lock, flags);
 
 	if (now && (now > timekeeping_suspend_time)) {
kernel/timer.c +0 -0
index a6c580a..5ec5490 100644

kernel/timer.c unregister_time_interpolator(struct time_interpolator *ti) · line 1504

Quoted 8 lines
kernel/timer.c +0 -2
@@ -1499,8 +1499,6 @@ unregister_time_interpolator(struct time_interpolator *ti)
 		prev = &curr->next;
 	}
 
-	clocksource_resume();
-
 	write_seqlock_irqsave(&xtime_lock, flags);
 	if (ti == time_interpolator) {
 		/* we lost the best time-interpolator: */

Urgh, that was probably me trying to manage the maelstrom from a million monkeys mucking in the same code for multiple months, sigh.

So what do "broke" and "fix" mean in this context? What are the consequences of this bug, and of its fix? Is the above appropriate for 2.6.21.x and if so why?

Thanks.

#2 lore raw
Quoted 6 lines · Andrew Morton

Urgh, that was probably me trying to manage the maelstrom from a million monkeys mucking in the same code for multiple months, sigh.

So what do "broke" and "fix" mean in this context? What are the consequences of this bug, and of its fix? Is the above appropriate for 2.6.21.x and if so why?

clocksource_resume() is not called except from unregister_time_interpolator(), which is definitely the wrong place.

No 2.6.21.x material, as the move of the timekeeping code happened after 2.6.21.

tglx

#3 lore raw
In reply to Thomas Gleixner
Quoted 4 lines · Thomas Gleixner

The time keeping code move to kernel/time/timekeeping.c broke the clocksource resume logic patch. Fix it up and move the clocksource_resume() call to the appropriate place.

Yeah, looks obvious enough. It had just enough context in the *wrong* place, that the patch would continue to apply if you used the default (insane) GNU patch semantics, because GNU patch defaults to --fuzz=2, and is thus ok if it can find even just a single line around the patch that is valid.

So it looks like Andrew's patch-application scripts happily added the "clocksource_resume()" to an insane place, because the one-line context was

kernel/time/timekeeping.c static int timekeeping_resume(struct sys_device *dev) · line 278

Quoted 4 lines
kernel/time/timekeeping.c +2 -0
+	clocksource_resume();
+
 	write_seqlock_irqsave(&xtime_lock, flags);

ie an empty line and a single write_seqlock_irqsave(). And those two lines could be found elsewhere in the wrong file.

There's a real reason I consider GNU patch defaults to be totally insane.

I personally use much stricter rules, but what happens is that Andrew's scripts will apply the patch to the wrong place, and then the diff gets *re-generated*, so by the time I see it, I see a nice diff that applies with no fuzz at all.

I don't think re-generating the diff is wrong, and in fact I think you have to do it, but I think Andrew should use "--fuzz=0" or at least "--fuzz=1" instead of the default 2. Yeah, it obviously causes more patch application failures, and it can be very irritating if *most* of those patches would have applied cleanly and correctly with --fuzz=2, but --fuzz=2 really is very dangerous. It literally just needed two lines to match in the wrong place (and as mentioned, those two lines can be trivial, like in the example - totally empty, even!)

Linus

#4 lore raw
Quoted 8 lines · On Mon, 14 May 2007 12:25:02 -0700 (PDT) Linus Torvalds…

I don't think re-generating the diff is wrong, and in fact I think you have to do it, but I think Andrew should use "--fuzz=0" or at least "--fuzz=1" instead of the default 2. Yeah, it obviously causes more patch application failures, and it can be very irritating if *most* of those patches would have applied cleanly and correctly with --fuzz=2, but --fuzz=2 really is very dangerous. It literally just needed two lines to match in the wrong place (and as mentioned, those two lines can be trivial, like in the example - totally empty, even!)

Yeah I played with that a while back and --fuzz=0 just broken everything.

--fuzz=1 seems acceptable though. I'll use that from now on.