On Wed, May 07, 2008 at 04:00:28PM +0200, Bram Matthys (Syzop) wrote:
> I'm experiencing the following problem:
> I upgraded from 2.6.20.1 to 2.6.25 on both the host and the uml's.
> Now, after some time (unsure how soon), the uml's appear to hang.
> It seems though, that they are not completely freezed, but just very very
> very slow (or rather.. 99% unresponsive).
> 
> top:
> ~  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
> ~ 5434 virt      20   0  128m  89m  89m R   99  4.5 269:40.81 linux
> ..so consuming nearly 100% cpu.

Are you using CONFIG_NOHZ?

There have been some recent time-related fixes.  Can you try the two
patches below and see if they help?

                      Jeff

-- 
Work email - jdike at linux dot intel dot com


Index: linux-2.6.22/arch/um/os-Linux/time.c
===================================================================
--- linux-2.6.22.orig/arch/um/os-Linux/time.c   2008-03-18 12:32:19.000000000 
-0400
+++ linux-2.6.22/arch/um/os-Linux/time.c        2008-03-24 12:46:26.000000000 
-0400
@@ -11,6 +11,7 @@
 #include "kern_constants.h"
 #include "os.h"
 #include "user.h"
+#include "kern_util.h"
 
 int set_interval(void)
 {
@@ -58,12 +59,17 @@ static inline long long timeval_to_ns(co
 long 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)
@@ -74,12 +80,51 @@ long long os_nsecs(void)
        return timeval_to_ns(&tv);
 }
 
+extern void alarm_handler(int sig, struct sigcontext *sc);
+
 #ifdef UML_CONFIG_NO_HZ
 static int after_sleep_interval(struct timespec *ts)
 {
        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 +147,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 +160,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 +171,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);
 }



Index: linux-2.6.22/arch/um/kernel/time.c
===================================================================
--- linux-2.6.22.orig/arch/um/kernel/time.c     2008-04-10 12:53:32.000000000 
-0400
+++ linux-2.6.22/arch/um/kernel/time.c  2008-04-14 10:30:00.000000000 -0400
@@ -75,7 +75,7 @@ static irqreturn_t um_timer(int irq, voi
 
 static cycle_t itimer_read(void)
 {
-       return os_nsecs();
+       return os_nsecs() / 1000;
 }
 
 static struct clocksource itimer_clocksource = {
@@ -83,7 +83,7 @@ static struct clocksource itimer_clockso
        .rating         = 300,
        .read           = itimer_read,
        .mask           = CLOCKSOURCE_MASK(64),
-       .mult           = 1,
+       .mult           = 1000,
        .shift          = 0,
        .flags          = CLOCK_SOURCE_IS_CONTINUOUS,
 };

-------------------------------------------------------------------------
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
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

Reply via email to