From: Anders <mail@flac.kalibalik.dk>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] Reduce redundant timer rearming
Date: Fri, 14 Dec 2007 00:03:03 +0100 [thread overview]
Message-ID: <4761BA27.5020307@flac.kalibalik.dk> (raw)
[-- Attachment #1: Type: text/plain, Size: 2227 bytes --]
The dynticks code in qemu sets and gets timers very often. These
are the system calls (strace -c) of qemu/kvm running an idle Linux
kernel at 250Hz for 10 seconds:
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
99.67 0.014391 1 23248 3187 ioctl
0.33 0.000047 0 43643 clock_gettime
0.00 0.000000 0 6375 gettimeofday
0.00 0.000000 0 6708 select
0.00 0.000000 0 3187 rt_sigaction
0.00 0.000000 0 9562 6375 rt_sigtimedwait
0.00 0.000000 0 10311 timer_settime
0.00 0.000000 0 12750 timer_gettime
------ ----------- ----------- --------- --------- ----------------
100.00 0.014438 115784 9562 total
The qemu_rearm_alarm_timer() function looks at vm_clock as well as
rt_clock timers, but is called from qemu_run_timers() which looks at
just one queue.
When an rt_clock timer has expired, the vm_clock iteration will rearm
with MIN_TIMER_REARM_US. This is not needed, since the timer in question
will be removed right away when qemu_run_timers() is run on the rt_clock
queue.
Moving the rearm call to after the two calls of qemu_run_timers() helps
a lot:
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
99.74 0.012590 1 22766 2706 ioctl
0.26 0.000033 0 27044 clock_gettime
0.00 0.000000 0 5413 gettimeofday
0.00 0.000000 0 5745 select
0.00 0.000000 0 2706 rt_sigaction
0.00 0.000000 0 8119 5413 rt_sigtimedwait
0.00 0.000000 0 5215 timer_settime
0.00 0.000000 0 5413 timer_gettime
------ ----------- ----------- --------- --------- ----------------
100.00 0.012623 82421 8119 total
Patch (based on kvm-userspace git) attached.
Cheers,
Anders.
[-- Attachment #2: qemu-single-rearm.diff --]
[-- Type: text/x-patch, Size: 707 bytes --]
diff --git a/qemu/vl.c b/qemu/vl.c
index 80ceb2f..2cd580d 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -1063,7 +1063,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)
@@ -7216,6 +7215,8 @@ void main_loop_wait(int timeout)
qemu_run_timers(&active_timers[QEMU_TIMER_REALTIME],
qemu_get_clock(rt_clock));
+ qemu_rearm_alarm_timer(alarm_timer);
+
/* Check bottom-halves last in case any of the earlier events triggered
them. */
qemu_bh_poll();
next reply other threads:[~2007-12-13 23:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-13 23:03 Anders [this message]
2007-12-13 23:17 ` [Qemu-devel] [PATCH] Reduce redundant timer rearming Anders Melchiorsen
2007-12-13 23:29 ` [Qemu-devel] [PATCH 2] " Anders
2007-12-14 0:05 ` [Qemu-devel] [PATCH 3] " Anders
2007-12-16 15:46 ` [Qemu-devel] [PATCH 4] " Anders
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=4761BA27.5020307@flac.kalibalik.dk \
--to=mail@flac.kalibalik.dk \
--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.