From: Jeff Dike <jdike@addtoit.com>
To: "Bram Matthys (Syzop)" <syzop@vulnscan.org>
Cc: user-mode-linux-devel@lists.sourceforge.net
Subject: Re: [uml-devel] umls unresponsive & consuming 100% cpu time
Date: Fri, 9 May 2008 11:45:52 -0400 [thread overview]
Message-ID: <20080509154552.GH10169@c2.user-mode-linux.org> (raw)
In-Reply-To: <4821B5FC.40307@vulnscan.org>
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
next prev parent reply other threads:[~2008-05-09 15:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-07 14:00 [uml-devel] umls unresponsive & consuming 100% cpu time Bram Matthys (Syzop)
2008-05-07 20:23 ` Nix
2008-05-08 10:02 ` [SPAM] " Bram Matthys (Syzop)
2008-05-09 15:45 ` Jeff Dike [this message]
2008-05-10 8:41 ` Bram Matthys (Syzop)
2008-05-13 15:40 ` Jeff Dike
2008-05-14 8:41 ` Sakari Ailus
2008-05-19 16:16 ` Jeff Dike
2008-05-31 9:16 ` Bram Matthys (Syzop)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080509154552.GH10169@c2.user-mode-linux.org \
--to=jdike@addtoit.com \
--cc=syzop@vulnscan.org \
--cc=user-mode-linux-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox