All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anders <mail@flac.kalibalik.dk>
To: avi@qumranet.com
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] qemu vl.c
Date: Wed, 19 Dec 2007 00:57:19 +0100	[thread overview]
Message-ID: <47685E5F.90503@flac.kalibalik.dk> (raw)
In-Reply-To: <4767F9D7.5060701@qumranet.com>

[-- Attachment #1: Type: text/plain, Size: 904 bytes --]

Avi Kivity wrote:

> Time in grub is completely off, Linux calibrate_delay() complains, 
> 'sleep 1' doesn't return, but FC6 x86-64 boots.
> 
> (this is with your patch on top of the re-applied patch I reverted earlier).
> 

Now I have updated my kvm checkout, and I immediately got trouble 
booting the guest. So it seems something has changed since I made my 
first patch.

What I could find is that the "env" variable in host_alarm_handler() is 
always NULL now? Then the expiry flag has to be set outside of that 
conditional, or alarms will never expire.

Also, an optimization of the new rearming in qemu_mod_timer() is that it 
should not be done if we are currently running the expired timers. It 
will be done after all the running is over, anyway.

Attached is a reworked patch with these changes, it should apply against 
your kvm git master (i.e. do not re-apply the reverted one).


Anders.

[-- Attachment #2: kvm-reduce-rearm.diff --]
[-- Type: text/x-patch, Size: 1723 bytes --]

diff --git a/qemu/vl.c b/qemu/vl.c
index 28c5df4..000df7e 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -850,6 +850,7 @@ struct qemu_alarm_timer {
 };
 
 #define ALARM_FLAG_DYNTICKS  0x1
+#define ALARM_FLAG_EXPIRED   0x2
 
 static inline int alarm_has_dynticks(struct qemu_alarm_timer *t)
 {
@@ -1061,6 +1062,12 @@ void qemu_mod_timer(QEMUTimer *ts, int64_t expire_time)
     ts->expire_time = expire_time;
     ts->next = *pt;
     *pt = ts;
+
+    /* Rearm if necessary  */
+    if ((alarm_timer->flags & ALARM_FLAG_EXPIRED) == 0
+        && pt == &active_timers[ts->clock->type]) {
+        qemu_rearm_alarm_timer(alarm_timer);
+    }
 }
 
 int qemu_timer_pending(QEMUTimer *ts)
@@ -1095,7 +1102,6 @@ static void qemu_run_timers(QEMUTimer **ptimer_head, int64_t current_time)
         /* run the callback (the timer list can be modified) */
         ts->cb(ts->opaque);
     }
-    qemu_rearm_alarm_timer(alarm_timer);
 }
 
 int64_t qemu_get_clock(QEMUClock *clock)
@@ -1215,6 +1221,8 @@ static void host_alarm_handler(int host_signum)
 #endif
         CPUState *env = next_cpu;
 
+        alarm_timer->flags |= ALARM_FLAG_EXPIRED;
+
         if (env) {
             /* stop the currently executing cpu because a timer occured */
             cpu_interrupt(env, CPU_INTERRUPT_EXIT);
@@ -7726,6 +7734,11 @@ void main_loop_wait(int timeout)
     qemu_run_timers(&active_timers[QEMU_TIMER_REALTIME],
                     qemu_get_clock(rt_clock));
 
+    if (alarm_timer->flags & ALARM_FLAG_EXPIRED) {
+        alarm_timer->flags &= ~(ALARM_FLAG_EXPIRED);
+        qemu_rearm_alarm_timer(alarm_timer);
+    }
+
     /* Check bottom-halves last in case any of the earlier events triggered
        them.  */
     qemu_bh_poll();

  reply	other threads:[~2007-12-18 23:57 UTC|newest]

Thread overview: 146+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-16 13:17 [Qemu-devel] qemu vl.c Andrzej Zaborowski
2007-12-16 14:30 ` Paul Brook
2007-12-16 15:26   ` Anders
2007-12-17  0:58     ` Paul Brook
2007-12-17 21:36       ` Avi Kivity
2007-12-17 23:46         ` Anders
2007-12-18  0:40           ` andrzej zaborowski
2007-12-18 16:48             ` Avi Kivity
2007-12-18 23:57               ` Anders [this message]
  -- strict thread matches above, loose matches on Subject: below --
2008-03-24  2:31 Paul Brook
2008-03-09 23:43 Aurelien Jarno
2008-02-03  3:45 Andrzej Zaborowski
2008-01-14  3:11 Andrzej Zaborowski
2008-01-08 19:32 Thiemo Seufer
2008-01-05 19:41 Andrzej Zaborowski
2007-12-24 13:58 Andrzej Zaborowski
2007-12-16 11:48 Andrzej Zaborowski
2007-12-06 22:11 Andrzej Zaborowski
2007-12-03  3:01 Andrzej Zaborowski
2007-11-24 23:27 Andrzej Zaborowski
2007-11-19  1:05 Jocelyn Mayer
2007-11-15 19:04 Paul Brook
2007-10-26 17:21 Thiemo Seufer
2007-10-21 23:20 Thiemo Seufer
2007-10-26 15:49 ` Stefan Weil
2007-10-26 16:48   ` Johannes Schindelin
2007-10-26 17:24     ` Thiemo Seufer
2007-10-04 19:59 Andrzej Zaborowski
2007-10-04 19:47 Andrzej Zaborowski
2007-09-17 21:25 Andrzej Zaborowski
2007-09-16 19:53 Thiemo Seufer
2007-08-28 22:21 Thiemo Seufer
2007-08-26 17:31 Thiemo Seufer
2007-08-26 17:29 Thiemo Seufer
2007-08-25  1:34 Thiemo Seufer
2007-08-24  1:46 Thiemo Seufer
2007-08-24  1:36 Thiemo Seufer
2007-08-24  1:26 Thiemo Seufer
2007-08-23 20:22 Paul Brook
2007-08-20 15:42 Thiemo Seufer
2007-08-19 22:09 Thiemo Seufer
2007-07-02 15:03 Andrzej Zaborowski
2007-07-02 13:31 Andrzej Zaborowski
2007-07-02 13:20 Andrzej Zaborowski
2007-06-29 23:26 Thiemo Seufer
2007-06-28 15:14 Thiemo Seufer
2007-06-28 14:05 Thiemo Seufer
2007-06-25 11:48 Thiemo Seufer
2007-06-28  8:24 ` Andreas Färber
2007-06-28  8:32   ` Andreas Färber
2007-06-23 16:01 Thiemo Seufer
2007-06-22  8:23 Andrzej Zaborowski
2007-06-21 23:34 Thiemo Seufer
2007-05-28  2:29 Paul Brook
2007-05-18 17:46 Andrzej Zaborowski
2007-05-13 14:54 Thiemo Seufer
2007-05-03 10:13 Andrzej Zaborowski
2007-04-28 20:49 Thiemo Seufer
2007-04-18 18:11 Thiemo Seufer
2007-04-18 17:56 Thiemo Seufer
2007-03-25 20:27 Thiemo Seufer
2007-03-25 15:58 Thiemo Seufer
2007-03-22 12:36 Thiemo Seufer
2007-03-19 16:36 Thiemo Seufer
2007-03-19 15:58 Thiemo Seufer
2007-03-11 18:54 Paul Brook
2007-02-28 21:59 Thiemo Seufer
2007-02-21 17:25 Thiemo Seufer
2007-02-19  1:10 Thiemo Seufer
2007-02-17 22:54 Thiemo Seufer
2007-02-10 21:50 Thiemo Seufer
2007-02-02  3:30 Thiemo Seufer
2007-02-03  4:20 ` Kazu
2007-02-05 11:52   ` Johannes Schindelin
2007-01-27 17:19 Paul Brook
2007-01-27 18:22 ` Stefan Weil
2007-01-27 18:38   ` Paul Brook
2007-01-27 17:11 Paul Brook
2007-01-09 19:44 Fabrice Bellard
2006-12-23 22:51 Thiemo Seufer
2006-12-23 15:37 Paul Brook
2006-12-22 21:20 Thiemo Seufer
2006-12-22 19:25 Thiemo Seufer
2006-12-22 17:29 Thiemo Seufer
2006-11-01  1:44 Paul Brook
2006-09-10 14:39 Paul Brook
2006-09-09 11:10 Fabrice Bellard
2006-08-17  9:43 Fabrice Bellard
2006-08-07 21:34 Fabrice Bellard
2006-08-06 13:36 Fabrice Bellard
2006-07-15 17:40 Paul Brook
2006-07-14  9:36 Fabrice Bellard
2006-06-26 20:03 Fabrice Bellard
2006-06-25 16:25 Fabrice Bellard
2006-05-01 13:33 Fabrice Bellard
2006-05-01 13:28 Fabrice Bellard
2006-05-01 13:23 Fabrice Bellard
2006-05-01 12:43 Fabrice Bellard
2006-04-30 22:20 Fabrice Bellard
2006-03-28 20:20 Paul Brook
2006-02-10 17:34 Paul Brook
2006-02-08 22:46 Fabrice Bellard
2006-02-01 21:29 Fabrice Bellard
2006-01-08 10:53 Fabrice Bellard
2005-12-18 19:09 Fabrice Bellard
2005-12-18 18:02 Fabrice Bellard
2005-11-27 19:10 Fabrice Bellard
2005-11-26 20:10 Fabrice Bellard
2005-11-23 21:01 Fabrice Bellard
2005-11-11  0:00 Fabrice Bellard
2005-09-03 21:33 Fabrice Bellard
2005-09-03 15:28 Fabrice Bellard
2005-06-05 14:49 Fabrice Bellard
2005-04-06 20:32 Fabrice Bellard
2005-03-01 21:28 Fabrice Bellard
2005-01-30 22:57 Fabrice Bellard
2005-01-26 21:56 Fabrice Bellard
2005-01-15 21:50 Fabrice Bellard
2005-01-09  0:22 Fabrice Bellard
2005-01-09  0:58 ` Phil Krylov
2005-01-09 10:48   ` Daniel Egger
2005-01-06 21:06 Fabrice Bellard
2005-01-03 23:48 Fabrice Bellard
2004-12-12 22:43 Fabrice Bellard
2004-11-14 15:48 Fabrice Bellard
2003-12-02 22:18 Fabrice Bellard
2003-11-16 19:46 Fabrice Bellard
2003-11-16 15:59 Fabrice Bellard
2003-11-11 13:36 Fabrice Bellard
2003-11-04 23:35 Fabrice Bellard
2003-10-30  1:11 Fabrice Bellard
2003-10-27 23:37 Fabrice Bellard
2003-10-27 21:18 Fabrice Bellard
2003-09-30 22:11 Fabrice Bellard
2003-09-30 21:40 Fabrice Bellard
2003-09-30 21:07 Fabrice Bellard
2003-09-16 21:46 Fabrice Bellard
2003-07-27 22:19 Fabrice Bellard
2003-07-26 18:11 Fabrice Bellard
2003-07-04 14:38 Fabrice Bellard
2003-07-01 15:07 Fabrice Bellard
2003-06-30 23:36 Fabrice Bellard
2003-06-30 13:06 Fabrice Bellard
2003-06-27 12:01 Fabrice Bellard
2003-06-25 16:20 Fabrice Bellard
2003-06-25  0:07 Fabrice Bellard

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=47685E5F.90503@flac.kalibalik.dk \
    --to=mail@flac.kalibalik.dk \
    --cc=avi@qumranet.com \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.