From: Paolo Bonzini <pbonzini@redhat.com>
To: Jan Kiszka <jan.kiszka@siemens.com>
Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH 0/4] Improve -icount, fix it with iothread
Date: Fri, 25 Feb 2011 20:33:56 +0100 [thread overview]
Message-ID: <4D680424.8050305@redhat.com> (raw)
In-Reply-To: <4D64F208.3070506@siemens.com>
On 02/23/2011 12:39 PM, Jan Kiszka wrote:
> You should try to trace the event flow in qemu, either via strace, via
> the built-in tracer (which likely requires a bit more tracepoints), or
> via a system-level tracer (ftrace / kernelshark).
The apparent problem is that 25% of cycles is spent in mutex locking and
unlocking. But in fact, the real problem is that 90% of the time is
spent doing something else than executing code.
QEMU exits _a lot_ due to the vm_clock timers. The deadlines are rarely more
than a few ms ahead, and at 1 MIPS that leaves room for executing a few
thousand instructions for each context switch. The iothread overhead
is what makes the situation so bad, because it takes a lot more time to
execute those instructions.
We do so many (almost) useless passes through cpu_exec_all that even
microoptimization helps, for example this:
--- a/cpus.c
+++ b/cpus.c
@@ -767,10 +767,6 @@ static void qemu_wait_io_event_common(CPUState *env)
{
CPUState *env;
- while (all_cpu_threads_idle()) {
- qemu_cond_timedwait(tcg_halt_cond, &qemu_global_mutex, 1000);
- }
-
qemu_mutex_unlock(&qemu_global_mutex);
/*
@@ -1110,7 +1111,15 @@ bool cpu_exec_all(void)
}
}
exit_request = 0;
+
+#ifdef CONFIG_IOTHREAD
+ while (all_cpu_threads_idle()) {
+ qemu_cond_timedwait(tcg_halt_cond, &qemu_global_mutex, 1000);
+ }
+ return true;
+#else
return !all_cpu_threads_idle();
+#endif
}
void set_numa_modes(void)
is enough to cut all_cpu_threads_idle from 9 to 4.5% (not unexpected: the
number of calls is halved). But it shouldn't be that high anyway, so
I'm not proposing the patch formally.
Additionally, the fact that the execution is 99.99% lockstep means you cannot
really overlap any part of the I/O and VCPU threads.
I found a couple of inaccuracies in my patches that already cut 50% of the
time, though.
> Did my patches contribute a bit to overhead reduction? They specifically
> target the costly vcpu/iothread switches in TCG mode (caused by TCGs
> excessive lock-holding times).
Yes, they cut 15%.
Paolo
next prev parent reply other threads:[~2011-02-25 19:34 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-21 8:51 [Qemu-devel] [PATCH 0/4] Improve -icount, fix it with iothread Paolo Bonzini
2011-02-21 8:51 ` [Qemu-devel] [PATCH 1/4] do not use qemu_icount_delta in the !use_icount case Paolo Bonzini
2011-02-21 8:51 ` [Qemu-devel] [PATCH 2/4] qemu_next_deadline should not consider host-time timers Paolo Bonzini
2011-02-21 8:51 ` [Qemu-devel] [PATCH 3/4] rewrite accounting of wait time to the vm_clock Paolo Bonzini
2011-02-21 8:51 ` [Qemu-devel] [PATCH 4/4] inline qemu_icount_delta Paolo Bonzini
2011-02-23 10:18 ` [Qemu-devel] Re: [PATCH 0/4] Improve -icount, fix it with iothread Edgar E. Iglesias
2011-02-23 10:25 ` Paolo Bonzini
2011-02-23 11:08 ` Edgar E. Iglesias
2011-02-23 11:39 ` Jan Kiszka
2011-02-23 12:40 ` Edgar E. Iglesias
2011-02-23 12:45 ` Jan Kiszka
2011-02-25 19:33 ` Paolo Bonzini [this message]
2011-02-23 12:42 ` Paolo Bonzini
2011-02-23 16:27 ` Edgar E. Iglesias
2011-02-23 16:32 ` Paolo Bonzini
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=4D680424.8050305@redhat.com \
--to=pbonzini@redhat.com \
--cc=edgar.iglesias@gmail.com \
--cc=jan.kiszka@siemens.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.