From d34e8f6e9d3a396c3327aa9807c83f9e1f4a7bd7 Mon Sep 17 00:00:00 2001 From: Michael Roth Date: Sat, 21 Jan 2012 11:13:53 -0600 Subject: main-loop: For tools, initialize timers as part of qemu_init_main_loop() 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. Reviewed-by: Paolo Bonzini Signed-off-by: Michael Roth Signed-off-by: Anthony Liguori --- main-loop.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'main-loop.h') diff --git a/main-loop.h b/main-loop.h index f9710136c9..4987041ce7 100644 --- a/main-loop.h +++ b/main-loop.h @@ -41,9 +41,21 @@ * 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. * -- cgit v1.2.3