From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1J4mJS-00055B-Cr for qemu-devel@nongnu.org; Tue, 18 Dec 2007 18:57:26 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1J4mJQ-000530-C0 for qemu-devel@nongnu.org; Tue, 18 Dec 2007 18:57:25 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J4mJQ-00052o-3V for qemu-devel@nongnu.org; Tue, 18 Dec 2007 18:57:24 -0500 Received: from 0xc2c0b63d.fbbft3nxf1.bf-dhcp.tele.dk ([194.192.182.61] helo=smtp.hotelhot.dk) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1J4mJP-0002HM-I8 for qemu-devel@nongnu.org; Tue, 18 Dec 2007 18:57:23 -0500 Message-ID: <47685E5F.90503@flac.kalibalik.dk> Date: Wed, 19 Dec 2007 00:57:19 +0100 From: Anders MIME-Version: 1.0 Subject: Re: [Qemu-devel] qemu vl.c References: <200712161430.35113.paul@codesourcery.com> <476543A0.9090207@flac.kalibalik.dk> <200712170058.35739.paul@codesourcery.com> <4766EBDB.1020308@qumranet.com> <3924.N1pNGSpdEBQ=.1197935190.squirrel@webmail.hotelhot.dk> <4767F9D7.5060701@qumranet.com> In-Reply-To: <4767F9D7.5060701@qumranet.com> Content-Type: multipart/mixed; boundary="------------080207050606000304010508" Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: avi@qumranet.com Cc: qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------080207050606000304010508 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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. --------------080207050606000304010508 Content-Type: text/x-patch; name="kvm-reduce-rearm.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="kvm-reduce-rearm.diff" 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(); --------------080207050606000304010508--