Re: [patch] CFS scheduler, -v19

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linus Torvalds
Date: Wednesday, July 18, 2007 - 9:03 am

On Tue, 17 Jul 2007, Ingo Molnar wrote:

Ok, that definitely should work.

Does the patch below help?


This is wrong. It's wrong for two reasons:

 - it really shouldn't be needed. I don't think "time()" has to be 
   *exactly* in sync, but I don't think it can be off by a third of a 
   second or whatever (as the "30% CPU load" would seem to imply)

 - gettimeofday works on a timeval, pthread_cond_timedwait() works on a 
   timespec.

So if it actually makes a difference, it makes a difference for the 
*wrong* reason: the time is still totally nonsensical in the tv_nsec field 
(because it actually got filled in with msecs!), but now the tv_sec field 
is in sync, so it hides the bug.

Anyway, hopefully the patch below might help. But we probably should make 
this whole thing a much more generic routine (ie we have our internal 
"getnstimeofday()" that still is missing the second-overflow logic, and 
that is quite possibly the one that triggers the "30% off" behaviour).

Ingo, I'd suggest:
 - ger rid of "timespec_add_ns()", or at least make it return a return 
   value for when it overflows.
 - make all the people who overflow into tv_sec call a "fix_up_seconds()" 
   thing that does the xtime overflow handling.

		Linus

---
Subject: time: make sure sys_gettimeofday() and sys_time() are in sync
From: Ingo Molnar <mingo@elte.hu>

make sure sys_gettimeofday() and sys_time() results are coherent.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 kernel/time/timekeeping.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)

Index: linux/kernel/time/timekeeping.c
===================================================================
--- linux.orig/kernel/time/timekeeping.c
+++ linux/kernel/time/timekeeping.c
@@ -92,6 +92,19 @@ static inline void __get_realtime_clock_
 	} while (read_seqretry(&xtime_lock, seq));
 
 	timespec_add_ns(ts, nsecs);
+	/*
+	 * Make sure xtime.tv_sec [returned by sys_time()] always
+	 * follows the gettimeofday() result precisely. This
+	 * condition is extremely unlikely, it can hit at most
+	 * once per second:
+	 */
+	if (unlikely(xtime.tv_sec != ts->tv_sec)) {
+		unsigned long flags;
+
+		write_seqlock_irqsave(&xtime_lock, flags);
+		update_wall_time();
+		write_sequnlock_irqrestore(&xtime_lock, flags);
+	}
 }
 
 /**

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[patch] CFS scheduler, -v19, Ingo Molnar, (Fri Jul 6, 10:33 am)
Re: [patch] CFS scheduler, -v19, Willy Tarreau, (Sun Jul 8, 10:46 am)
Re: [patch] CFS scheduler, -v19, Ingo Molnar, (Mon Jul 9, 3:39 pm)
Re: [patch] CFS scheduler, -v19, Mike Galbraith, (Tue Jul 10, 1:08 am)
Re: [patch] CFS scheduler, -v19, Bill Davidsen, (Wed Jul 11, 10:26 am)
Re: [patch] CFS scheduler, -v19, Ingo Molnar, (Wed Jul 11, 1:55 pm)
Re: [patch] CFS scheduler, -v19, Bill Davidsen, (Thu Jul 12, 5:41 am)
Re: [patch] CFS scheduler, -v19, Bill Davidsen, (Fri Jul 13, 2:19 pm)
Re: [patch] CFS scheduler, -v19, Markus, (Sat Jul 14, 4:34 am)
Re: [patch] CFS scheduler, -v19, Markus, (Sat Jul 14, 8:11 am)
Re: [patch] CFS scheduler, -v19, Ed Tomlinson, (Sat Jul 14, 10:19 am)
Re: [patch] CFS scheduler, -v19, Mike Galbraith, (Sat Jul 14, 10:25 pm)
Re: [patch] CFS scheduler, -v19, Markus, (Sun Jul 15, 5:53 am)
Re: [patch] CFS scheduler, -v19, Mike Galbraith, (Sun Jul 15, 12:46 pm)
Re: [patch] CFS scheduler, -v19, Markus, (Sun Jul 15, 2:11 pm)
Re: [patch] CFS scheduler, -v19, Mike Galbraith, (Sun Jul 15, 11:42 pm)
Re: [patch] CFS scheduler, -v19, Ingo Molnar, (Mon Jul 16, 1:00 am)
Re: [patch] CFS scheduler, -v19, Ingo Molnar, (Mon Jul 16, 2:17 am)
Re: [patch] CFS scheduler, -v19, Ingo Molnar, (Mon Jul 16, 2:41 am)
Re: [patch] CFS scheduler, -v19, Ed Tomlinson, (Mon Jul 16, 4:10 am)
Re: [patch] CFS scheduler, -v19, Markus, (Mon Jul 16, 10:59 am)
Re: [patch] CFS scheduler, -v19, Chuck Ebbert, (Mon Jul 16, 2:34 pm)
Re: [patch] CFS scheduler, -v19, Ingo Molnar, (Mon Jul 16, 2:55 pm)
Re: [patch] CFS scheduler, -v19, Bill Davidsen, (Mon Jul 16, 9:22 pm)
Re: [patch] CFS scheduler, -v19, Ian Kent, (Mon Jul 16, 10:01 pm)
Re: [patch] CFS scheduler, -v19, Ingo Molnar, (Tue Jul 17, 12:37 am)
Re: [patch] CFS scheduler, -v19, Ingo Molnar, (Tue Jul 17, 12:45 am)
Re: [patch] CFS scheduler, -v19, Ian Kent, (Tue Jul 17, 4:17 am)
Re: [patch] CFS scheduler, -v19, Markus, (Tue Jul 17, 6:06 am)
Re: [patch] CFS scheduler, -v19, Chuck Ebbert, (Tue Jul 17, 9:30 am)
Re: [patch] CFS scheduler, -v19, Ingo Molnar, (Tue Jul 17, 10:06 am)
Re: [patch] CFS scheduler, -v19, Ingo Molnar, (Tue Jul 17, 10:13 am)
Re: [patch] CFS scheduler, -v19, Ingo Molnar, (Tue Jul 17, 10:16 am)
Re: [patch] CFS scheduler, -v19, Markus, (Tue Jul 17, 12:42 pm)
Re: [patch] CFS scheduler, -v19, Ingo Molnar, (Tue Jul 17, 1:09 pm)
Re: [patch] CFS scheduler, -v19, Linus Torvalds, (Tue Jul 17, 1:37 pm)
Re: [patch] CFS scheduler, -v19, Ingo Molnar, (Tue Jul 17, 1:43 pm)
RE: [patch] CFS scheduler, -v19, David Schwartz, (Tue Jul 17, 2:16 pm)
Re: [patch] CFS scheduler, -v19, Willy Tarreau, (Tue Jul 17, 2:44 pm)
Re: [patch] CFS scheduler, -v19, Markus, (Tue Jul 17, 3:03 pm)
Re: [patch] CFS scheduler, -v19, Bill Davidsen, (Tue Jul 17, 6:24 pm)
RE: [patch] CFS scheduler, -v19, Ian Kent, (Tue Jul 17, 10:59 pm)
Re: [patch] CFS scheduler, -v19, Ian Kent, (Tue Jul 17, 11:19 pm)
Re: [patch] CFS scheduler, -v19, Ingo Molnar, (Wed Jul 18, 12:54 am)
Re: [patch] CFS scheduler, -v19, Bill Davidsen, (Wed Jul 18, 6:50 am)
Re: [patch] CFS scheduler, -v19, Linus Torvalds, (Wed Jul 18, 9:03 am)
Re: [patch] CFS scheduler, -v19, Linus Torvalds, (Wed Jul 18, 10:23 am)
Re: [patch] CFS scheduler, -v19, Ian Kent, (Wed Jul 18, 10:31 am)
Re: [patch] CFS scheduler, -v19, Bill Davidsen, (Wed Jul 18, 2:37 pm)
Re: [patch] CFS scheduler, -v19, Ingo Molnar, (Thu Jul 19, 1:16 am)
Re: [patch] CFS scheduler, -v19, Ingo Molnar, (Thu Jul 19, 1:53 am)
Re: [patch] CFS scheduler, -v19, Ingo Molnar, (Thu Jul 19, 7:32 am)
Re: [patch] CFS scheduler, -v19, Bill Davidsen, (Thu Jul 19, 10:06 am)
Re: [patch] CFS scheduler, -v19, Ingo Molnar, (Thu Jul 19, 10:10 am)
Re: [patch] CFS scheduler, -v19, Ingo Molnar, (Thu Jul 19, 10:17 am)
Re: [patch] CFS scheduler, -v19, Bill Davidsen, (Thu Jul 19, 10:26 am)
Re: [patch] CFS scheduler, -v19, Ingo Molnar, (Thu Jul 19, 10:42 am)
Re: [patch] CFS scheduler, -v19, Bill Davidsen, (Thu Jul 19, 7:32 pm)
Re: [patch] CFS scheduler, -v19, Markus, (Fri Jul 20, 3:26 pm)
Re: [patch] CFS scheduler, -v19, Markus, (Thu Aug 9, 10:34 am)
Re: [patch] CFS scheduler, -v19, Ingo Molnar, (Fri Aug 10, 12:46 am)
Re: [patch] CFS scheduler, -v19, Markus, (Tue Aug 14, 10:15 am)
Re: [patch] CFS scheduler, -v19, Markus, (Tue Oct 16, 5:02 pm)