UML - Track and make up lost ticks
PATCH 11/19 UML - Track and make up lost ticks
Alarm delivery could be noticably late in the !CONFIG_NOHZ case because lost ticks weren't being taken into account. This is now treated more carefully, with the time between ticks being calculated and the appropriate number of ticks delivered to the timekeeping system.
--- arch/um/os-Linux/time.c | 54 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 4 deletions(-)
arch/um/os-Linux/time.c +50 -4
@@ -9,7 +9,9 @@#include <time.h> #include <sys/time.h> #include "kern_constants.h" +#include "kern_util.h" #include "os.h" +#include "process.h" #include "user.h" int set_interval (void )
@@ -58,12 +60,17 @@ static inline long long timeval_to_ns(colong long disable_timer (void ) {struct itimerval time = ((struct itimerval ) { {0 ,0 }, {0 ,0 } }); +int remain, max =UM_NSEC_PER_SEC /UM_HZ ;if (setitimer (ITIMER_VIRTUAL , &time, &time) <0 )printk (UM_KERN_ERR "disable_timer - setitimer failed, " "errno = %d\n" , errno); -return timeval_to_ns (&time.it_value); + remain =timeval_to_ns (&time.it_value); +if (remain > max) + remain = max; + +return remain; }long long os_nsecs (void )
@@ -79,7 +86,44 @@ static int after_sleep_interval(struct t {return 0 ; } + +static void deliver_alarm (void ) +{ +alarm_handler (SIGVTALRM ,NULL ); +} + +static unsigned long long sleep_time (unsigned long long nsecs) +{ +return nsecs; +} +#else +unsigned long long last_tick; +unsigned long long skew; + +static void deliver_alarm (void ) +{ +unsigned long long this_tick =os_nsecs (); +int one_tick =UM_NSEC_PER_SEC /UM_HZ ; + +if (last_tick ==0 ) + last_tick = this_tick - one_tick; + + skew += this_tick - last_tick; + +while (skew >= one_tick) { +alarm_handler (SIGVTALRM ,NULL ); + skew -= one_tick; + } + + last_tick = this_tick; +} + +static unsigned long long sleep_time (unsigned long long nsecs) +{ +return nsecs > skew ? nsecs - skew :0 ; +} +static inline long long timespec_to_us (const struct timespec *ts) { return ((long long) ts->tv_sec * UM_USEC_PER_SEC) +
@@ -102,6 +146,8 @@ static int after_sleep_interval(struct t*/ if (start_usecs > usec) start_usecs = usec; + + start_usecs -= skew /UM_NSEC_PER_USEC ; tv = ((struct timeval ) { .tv_sec = start_usecs /UM_USEC_PER_SEC , .tv_usec = start_usecs %UM_USEC_PER_SEC }); interval = ((struct itimerval ) { {0 , usec }, tv });
@@ -113,8 +159,6 @@ static int after_sleep_interval(struct t }#endif -extern void alarm_handler (int sig,struct sigcontext *sc); -void idle_sleep (unsigned long long nsecs) {struct timespec ts;
@@ -126,10 +170,12 @@ void idle_sleep(unsigned long long nsecs*/ if (nsecs ==0 ) nsecs =UM_NSEC_PER_SEC /UM_HZ ; + + nsecs =sleep_time (nsecs); ts = ((struct timespec ) { .tv_sec = nsecs /UM_NSEC_PER_SEC , .tv_nsec = nsecs %UM_NSEC_PER_SEC });if (nanosleep (&ts, &ts) ==0 ) -alarm_handler (SIGVTALRM ,NULL ); +deliver_alarm ();after_sleep_interval (&ts); }
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
On 25 Apr 2008, Jeff Dike stated, in part:
arch/um/os-Linux/time.c static int after_sleep_interval(struct t
Quoted 8 lines
Index:
linux-2.6-git/arch/um/os-Linux/time.c
===================================================================arch/um/os-Linux/time.c +2
-2+alarm_handler (SIGVTALRM ,NULL ); +alarm_handler (SIGVTALRM ,NULL ); -extern void alarm_handler (int sig,struct sigcontext *sc); -alarm_handler (SIGVTALRM ,NULL );
Yet, in arch/um/include/process.h, we see, unchanged since the year dot, the obviously wrong prototype:
extern void alarm_handler(int sig, struct sigcontext sc);
Hence:
CC arch/um/os-Linux/time.oarch/um/os-Linux/time.c: In function ‘deliver_alarm’:arch/um/os-Linux/time.c:119: error: incompatible type for argument 2 of ‘alarm_handler’ make[1]: *** [arch/um/os-Linux/time.o] Error 1
make: *** [arch/um/os-Linux] Error 2
Fix trivial:
Signature · 25 lines
Index: linux/arch/um/include/process.h =================================================================== --- linux.orig/arch/um/include/process.h 2006-07-09 14:19:52.000000000 +0100 +++ linux/arch/um/include/process.h 2008-04-29 19:49:49.000000000 +0100 @@ -8,8 +8,8 @@ #include <signal.h> -extern void sig_handler(int sig, struct sigcontext sc); -extern void alarm_handler(int sig, struct sigcontext sc); +extern void sig_handler(int sig, struct sigcontext *sc); +extern void alarm_handler(int sig, struct sigcontext *sc); #endif ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ User-mode-linux-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Quoted 32 lines · Nix
On 25 Apr 2008, Jeff Dike stated, in part:
arch/um/os-Linux/time.c static int after_sleep_interval(struct t
Quoted 8 lines
Index:
linux-2.6-git/arch/um/os-Linux/time.c
===================================================================arch/um/os-Linux/time.c +2
-2+alarm_handler (SIGVTALRM ,NULL ); +alarm_handler (SIGVTALRM ,NULL ); -extern void alarm_handler (int sig,struct sigcontext *sc); -alarm_handler (SIGVTALRM ,NULL );Yet, in
arch/um/include/process.h, we see, unchanged since the year dot, the obviously wrong prototype:extern void
alarm_handler(int sig, struct sigcontext sc);Hence:
CC
arch/um/os-Linux/time.oarch/um/os-Linux/time.c: In function ‘deliver_alarm’:arch/um/os-Linux/time.c:119: error: incompatible type for argument 2 of ‘alarm_handler’ make[1]: *** [arch/um/os-Linux/time.o] Error 1
make: *** [arch/um/os-Linux] Error 2Fix trivial:
Signed-off-by Nick Alcock <[email protected]>Signature · 2 lines
Index: linux/arch/um/include/process.h ===================================================================
arch/um/include/process.h line 14
Quoted 9 lines
arch/um/include/process.h +2
-2@@ -8,8 +8,8 @@#include <signal.h> -extern void sig_handler (int sig,struct sigcontext sc); -extern void alarm_handler (int sig,struct sigcontext sc); +extern void sig_handler (int sig,struct sigcontext *sc); +extern void alarm_handler (int sig,struct sigcontext *sc);#endif
Crap, I fixed that, but forgot to quilt add it, I guess.
ACK.
Jeff
Signature · 11 lines
Work email - jdike at linux dot intel dot com ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ User-mode-linux-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Quoted 41 lines · On Tue, 29 Apr 2008 16:29:25 -0400 Jeff Dike <[email protected]> wrote:
Quoted 40 lines · Nix
On 25 Apr 2008, Jeff Dike stated, in part:
arch/um/os-Linux/time.c static int after_sleep_interval(struct t
Quoted 8 lines
Index:
linux-2.6-git/arch/um/os-Linux/time.c
===================================================================arch/um/os-Linux/time.c +2
-2+alarm_handler (SIGVTALRM ,NULL ); +alarm_handler (SIGVTALRM ,NULL ); -extern void alarm_handler (int sig,struct sigcontext *sc); -alarm_handler (SIGVTALRM ,NULL );Yet, in
arch/um/include/process.h, we see, unchanged since the year dot, the obviously wrong prototype:extern void
alarm_handler(int sig, struct sigcontext sc);Hence:
CC
arch/um/os-Linux/time.oarch/um/os-Linux/time.c: In function ‘deliver_alarm’:arch/um/os-Linux/time.c:119: error: incompatible type for argument 2 of ‘alarm_handler’ make[1]: *** [arch/um/os-Linux/time.o] Error 1
make: *** [arch/um/os-Linux] Error 2Fix trivial:
Signed-off-by Nick Alcock <[email protected]>Signature · 2 lines
Index: linux/arch/um/include/process.h ===================================================================arch/um/include/process.h +2
-2@@ -8,8 +8,8 @@#include <signal.h> -extern void sig_handler (int sig,struct sigcontext sc); -extern void alarm_handler (int sig,struct sigcontext sc); +extern void sig_handler (int sig,struct sigcontext *sc); +extern void alarm_handler (int sig,struct sigcontext *sc);
Quoted 6 lines
arch/um/include/process.h line 14
Quoted 1 line
arch/um/include/process.h +0
-0#endif Crap, I fixed that, but forgot to quilt add it, I guess.
ACK.
This fix was already present in your "[PATCH 4/19] UML - Random driver fixes".
Perhaps we broke bisection?
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Quoted 1 line · Andrew Morton
This fix was already present in your "[PATCH 4/19] UML - Random driver fixes".
Ah, so that's where it ended up.
Quoted 1 line
Perhaps we broke bisection?
No doubt. Drop those two and I'll send fixed ones.
Jeff
Signature · 11 lines
Work email - jdike at linux dot intel dot com ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ User-mode-linux-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Quoted 4 lines · On Tue, 6 May 2008 17:44:35 -0400 Jeff Dike <[email protected]> wrote:
Quoted 1 line · Andrew Morton
This fix was already present in your "[PATCH 4/19] UML - Random driver fixes".
Ah, so that's where it ended up.
Strange that the bug has always been there. Some other change made it apparent?
Quoted 3 lines
Quoted 1 line
Perhaps we broke bisection?
No doubt. Drop those two and I'll send fixed ones.
OK. uml-random-driver-style-fixes.patch needed to go also.
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
On 6 May 2008, Andrew Morton uttered the following:
Quoted 10 lines
Quoted 4 lines · On Tue, 6 May 2008 17:44:35 -0400 Jeff Dike <[email protected]> wrote:
Quoted 1 line · Andrew Morton
This fix was already present in your "[PATCH 4/19] UML - Random driver fixes".
Ah, so that's where it ended up.
Strange that the bug has always been there. Some other change made it apparent?
Yeah, there was a re-prototyping of the broken prototype above the only use outside the file where the function is defined, and this patch removed that re-prottyping. :)
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel