From: Jan Kiszka <jan.kiszka@web.de>
To: Anthony Liguori <anthony@codemonkey.ws>,
Marcelo Tosatti <mtosatti@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [7241] qemu: refactor main_loop (Marcelo Tosatti)
Date: Wed, 29 Apr 2009 00:34:55 +0200 [thread overview]
Message-ID: <49F7848F.7020708@web.de> (raw)
In-Reply-To: <E1LxPkM-0002rf-9A@cvs.savannah.gnu.org>
[-- Attachment #1: Type: text/plain, Size: 3109 bytes --]
Anthony Liguori wrote:
> Revision: 7241
> http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=7241
> Author: aliguori
> Date: 2009-04-24 18:03:33 +0000 (Fri, 24 Apr 2009)
> Log Message:
> -----------
> qemu: refactor main_loop (Marcelo Tosatti)
>
> Break main loop into 3 main functions.
I suspect this patch comes with a race between SIGALRM and
qemu_calculate_timeout() so that I see occasional freezes of exactly 5
seconds if the IO thread is disabled. I do not yet understand what
happens precisely or if this patch only widens an already existing race
window in the old code, but I'm on it.
Besides that...
>
> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
>
> Modified Paths:
> --------------
> trunk/vl.c
>
> Modified: trunk/vl.c
> ===================================================================
> --- trunk/vl.c 2009-04-24 18:03:29 UTC (rev 7240)
> +++ trunk/vl.c 2009-04-24 18:03:33 UTC (rev 7241)
> @@ -273,7 +273,7 @@
>
> static CPUState *cur_cpu;
> static CPUState *next_cpu;
> -static int event_pending = 1;
> +static int timer_alarm_pending = 1;
> /* Conversion factor from emulated instructions to virtual clock ticks. */
> static int icount_time_shift;
> /* Arbitrarily pick 1MIPS as the minimum allowable speed. */
> @@ -1360,7 +1360,7 @@
> }
> #endif
> }
> - event_pending = 1;
> + timer_alarm_pending = 1;
> qemu_notify_event();
> }
> }
> @@ -3879,153 +3879,175 @@
>
> }
>
> -static int main_loop(void)
> +static int qemu_cpu_exec(CPUState *env)
> {
> - int ret, timeout;
> + int ret;
> #ifdef CONFIG_PROFILER
> int64_t ti;
> #endif
> +
> +#ifdef CONFIG_PROFILER
> + ti = profile_getclock();
> +#endif
> + if (use_icount) {
> + int64_t count;
> + int decr;
> + qemu_icount -= (env->icount_decr.u16.low + env->icount_extra);
> + env->icount_decr.u16.low = 0;
> + env->icount_extra = 0;
> + count = qemu_next_deadline();
> + count = (count + (1 << icount_time_shift) - 1)
> + >> icount_time_shift;
> + qemu_icount += count;
> + decr = (count > 0xffff) ? 0xffff : count;
> + count -= decr;
> + env->icount_decr.u16.low = decr;
> + env->icount_extra = count;
> + }
> + ret = cpu_exec(env);
> +#ifdef CONFIG_PROFILER
> + qemu_time += profile_getclock() - ti;
> +#endif
> + if (use_icount) {
> + /* Fold pending instructions back into the
> + instruction counter, and clear the interrupt flag. */
> + qemu_icount -= (env->icount_decr.u16.low
> + + env->icount_extra);
> + env->icount_decr.u32 = 0;
> + env->icount_extra = 0;
> + }
> + return ret;
> +}
> +
> +static int cpu_has_work(CPUState *env)
...this naming is suboptimal. There is already cpu_has_work() in
target-*/exec.h which is at least confusing. Please rename.
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]
next prev parent reply other threads:[~2009-04-28 22:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-24 18:03 [Qemu-devel] [7241] qemu: refactor main_loop (Marcelo Tosatti) Anthony Liguori
2009-04-28 22:34 ` Jan Kiszka [this message]
2009-04-28 22:41 ` [Qemu-devel] " Marcelo Tosatti
2009-04-28 22:55 ` Jan Kiszka
2009-04-28 23:02 ` Marcelo Tosatti
2009-04-29 7:18 ` Gerd Hoffmann
2009-04-29 7:54 ` Jan Kiszka
2009-04-29 9:47 ` Gerd Hoffmann
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=49F7848F.7020708@web.de \
--to=jan.kiszka@web.de \
--cc=anthony@codemonkey.ws \
--cc=mtosatti@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).