From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com
Subject: [Qemu-devel] [PATCH 2/6] main-loop: For tools, initialize timers as part of qemu_init_main_loop()
Date: Wed, 25 Jan 2012 09:26:22 -0600 [thread overview]
Message-ID: <1327505186-18328-3-git-send-email-mdroth@linux.vnet.ibm.com> (raw)
In-Reply-To: <1327505186-18328-1-git-send-email-mdroth@linux.vnet.ibm.com>
In some cases initializing the alarm timers can lead to non-negligable
overhead from programs that link against qemu-tool.o. At least,
setting a max-resolution WinMM alarm timer via mm_start_timer() (the
current default for Windows) can increase the "tick rate" on Windows
OSs and affect frequency scaling, and in the case of tools that run
in guest OSs such has qemu-ga, the impact can be fairly dramatic
(+20%/20% user/sys time on a core 2 processor was observed from an idle
Windows XP guest).
This patch doesn't address the issue directly (not sure what a good
solution would be for Windows, or what other situations it might be
noticeable), but it at least limits the scope of the issue to programs
that "opt-in" to using the main-loop.c functions by only enabling alarm
timers when qemu_init_main_loop() is called, which is already required
to make use of those facilities, so existing users shouldn't be
affected.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
main-loop.c | 2 +-
main-loop.h | 12 ++++++++++++
qemu-tool.c | 3 ++-
vl.c | 5 +++++
4 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/main-loop.c b/main-loop.c
index 62d95b9..db23de0 100644
--- a/main-loop.c
+++ b/main-loop.c
@@ -199,7 +199,7 @@ static int qemu_signal_init(void)
}
#endif
-int qemu_init_main_loop(void)
+int main_loop_init(void)
{
int ret;
diff --git a/main-loop.h b/main-loop.h
index f971013..4987041 100644
--- a/main-loop.h
+++ b/main-loop.h
@@ -41,10 +41,22 @@
* SIGUSR2, thread signals (SIGFPE, SIGILL, SIGSEGV, SIGBUS) and real-time
* signals if available. Remember that Windows in practice does not have
* signals, though.
+ *
+ * In the case of QEMU tools, this will also start/initialize timers.
*/
int qemu_init_main_loop(void);
/**
+ * main_loop_init: Initializes main loop
+ *
+ * Internal (but shared for compatibility reasons) initialization routine
+ * for the main loop. This should not be used by applications directly,
+ * use qemu_init_main_loop() instead.
+ *
+ */
+int main_loop_init(void);
+
+/**
* main_loop_wait: Run one iteration of the main loop.
*
* If @nonblocking is true, poll for events, otherwise suspend until
diff --git a/qemu-tool.c b/qemu-tool.c
index 6b69668..183a583 100644
--- a/qemu-tool.c
+++ b/qemu-tool.c
@@ -83,11 +83,12 @@ void qemu_clock_warp(QEMUClock *clock)
{
}
-static void __attribute__((constructor)) init_main_loop(void)
+int qemu_init_main_loop(void)
{
init_clocks();
init_timer_alarm();
qemu_clock_enable(vm_clock, false);
+ return main_loop_init();
}
void slirp_select_fill(int *pnfds, fd_set *readfds,
diff --git a/vl.c b/vl.c
index 57378b6..9d14cc8 100644
--- a/vl.c
+++ b/vl.c
@@ -2159,6 +2159,11 @@ static void free_and_trace(gpointer mem)
free(mem);
}
+int qemu_init_main_loop(void)
+{
+ return main_loop_init();
+}
+
int main(int argc, char **argv, char **envp)
{
const char *gdbstub_dev = NULL;
--
1.7.4.1
next prev parent reply other threads:[~2012-01-25 15:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-25 15:26 [Qemu-devel] [PULL 0/6] qemu-ga queue and qemu-tool fixes Michael Roth
2012-01-25 15:26 ` [Qemu-devel] [PATCH 1/6] main-loop: Fix SetEvent() on uninitialized handle on win32 Michael Roth
2012-01-25 15:26 ` Michael Roth [this message]
2012-01-25 15:26 ` [Qemu-devel] [PATCH 3/6] qemu-ga: Add schema documentation for types Michael Roth
2012-01-25 15:26 ` [Qemu-devel] [PATCH 4/6] qemu-ga: add guest-set-support-level command Michael Roth
2012-01-25 15:26 ` [Qemu-devel] [PATCH 5/6] qemu-ga: set O_NONBLOCK for serial channels Michael Roth
2012-01-25 15:26 ` [Qemu-devel] [PATCH 6/6] qemu-ga: Add the guest-suspend command Michael Roth
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=1327505186-18328-3-git-send-email-mdroth@linux.vnet.ibm.com \
--to=mdroth@linux.vnet.ibm.com \
--cc=aliguori@us.ibm.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).