From: Luca Tettamanti <kronos.it-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Ulrich Schreiner
<ulrich.schreiner-sZDnKEZIvs8b1SvskN2V4Q@public.gmane.org>
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
Avi Kivity <avik-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
Subject: Re: kvm very slow
Date: Tue, 7 Aug 2007 22:49:22 +0200 [thread overview]
Message-ID: <20070807204922.GA27976@dreamland.darkstar.lan> (raw)
In-Reply-To: <68676e00708070508w3d9e5ab8gd26263c44bf59f0d-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
Il Tue, Aug 07, 2007 at 02:08:08PM +0200, Luca ha scritto:
> On 8/7/07, Dor Laor <dor.laor-atKUWr5tajBWk0Htik3J/w@public.gmane.org> wrote:
> > Luca claims the HPET intefer the RTC. Can it be disabled? ( I know some
> > new chipsets implement rtc using HPET).
>
> Basically HPET can operate in legacy mode - where it uses the same IRQ
> as the RTC (and RTC won't deliver any interrupt) - or in "standard"
> mode where the IO-APIC can be configured to deliver the interrupt on
> any line. ATM Linux can only use the legacy mode.
> You can of course disable HPET, but then it won't be available for
> in-kernel timekeeping (in case e.g. the TSC is not stable/synced). I'd
> rather add support for HPET as timer in QEMU...
Something like this. Ulrich can you give it a try:
---
Patch against current GIT, but also applies to kvm-33.
Run kvm with -use-hpet.
qemu/vl.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 60 insertions(+), 2 deletions(-)
diff --git a/qemu/vl.c b/qemu/vl.c
index 4ad39f1..36628af 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -54,6 +54,7 @@
#include <pty.h>
#include <malloc.h>
#include <linux/rtc.h>
+#include <linux/hpet.h>
#include <linux/ppdev.h>
#endif
#endif
@@ -996,8 +997,9 @@ static void host_alarm_handler(int host_signum)
static int use_rtc = 1;
static int rtc_fd;
+static int use_hpet;
-static int start_rtc_timer(void)
+static int enable_rtc(void)
{
rtc_fd = open("/dev/rtc", O_RDONLY);
if (rtc_fd < 0)
@@ -1017,6 +1019,56 @@ static int start_rtc_timer(void)
return 0;
}
+static char default_hpet[] = "/dev/hpet";
+
+static int enable_hpet(void)
+{
+ struct hpet_info info;
+ int r;
+
+ rtc_fd = open(default_hpet, O_RDONLY);
+ if (rtc_fd < 0)
+ return -1;
+
+ /* Set frequency */
+ r = ioctl(rtc_fd, HPET_IRQFREQ, RTC_FREQ);
+ if (r < 0) {
+ fprintf(stderr, "Could not configure '/dev/hpet' to have a 1024 Hz timer. This is not a fatal\n"
+ "error, but for better emulation accuracy type:\n"
+ "'echo 1024 > /proc/sys/dev/hpet/max-user-freq' as root.\n");
+ goto fail;
+ }
+
+ /* Check capabilities */
+ r = ioctl(rtc_fd, HPET_INFO, &info);
+ if (r < 0)
+ goto fail;
+
+ /* Enable peridic mode */
+ r = ioctl(rtc_fd, HPET_EPI, 0);
+ if (info.hi_flags && (r < 0))
+ goto fail;
+
+ /* Enable interrupt */
+ r = ioctl(rtc_fd, HPET_IE_ON, 0);
+ if (r < 0)
+ goto fail;
+
+ pit_min_timer_count = PIT_FREQ / RTC_FREQ;
+
+ return 0;
+fail:
+ close(rtc_fd);
+ return -1;
+}
+
+static int start_rtc_timer(void)
+{
+ if (use_hpet)
+ return enable_hpet();
+ else
+ return enable_rtc();
+}
#else
static int start_rtc_timer(void)
@@ -1090,7 +1142,7 @@ static void init_timer_alarm(void)
2.6 kernels */
if (itv.it_interval.tv_usec > 1000 || 1) {
/* try to use /dev/rtc to have a faster timer */
- if (!use_rtc || (start_rtc_timer() < 0))
+ if ((!use_rtc && !use_hpet) || (start_rtc_timer() < 0))
goto use_itimer;
/* disable itimer */
itv.it_interval.tv_sec = 0;
@@ -6482,6 +6534,7 @@ void help(void)
"-tdf inject timer interrupts that got lost\n"
#if defined(__linux__)
"-no-rtc don't use /dev/rtc for timer alarm (do use gettimeofday)\n"
+ "-use-rtc use /dev/hpet (HPET) for timer alarm (do use gettimeofday)\n"
#endif
"-option-rom rom load a file, rom, into the option ROM space\n"
"\n"
@@ -6574,6 +6627,7 @@ enum {
QEMU_OPTION_tdf,
#if defined(__linux__)
QEMU_OPTION_no_rtc,
+ QEMU_OPTION_use_hpet,
#endif
QEMU_OPTION_cpu_vendor,
};
@@ -6671,6 +6725,7 @@ const QEMUOption qemu_options[] = {
{ "tdf", 0, QEMU_OPTION_tdf }, /* enable time drift fix */
#if defined(__linux__)
{ "no-rtc", 0, QEMU_OPTION_no_rtc },
+ { "use-hpet", 0, QEMU_OPTION_use_hpet },
#endif
{ "cpu-vendor", HAS_ARG, QEMU_OPTION_cpu_vendor },
{ NULL },
@@ -7395,6 +7450,9 @@ int main(int argc, char **argv)
case QEMU_OPTION_no_rtc:
use_rtc = 0;
break;
+ case QEMU_OPTION_use_hpet:
+ use_hpet = 1;
+ break;
#endif
case QEMU_OPTION_cpu_vendor:
cpu_vendor_string = optarg;
Luca
--
I went to God just to see
And I was looking at me
Saw heaven and hell were lies
When I'm God everyone dies
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
next prev parent reply other threads:[~2007-08-07 20:49 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-01 5:22 kvm very slow Ulrich Schreiner
2007-08-01 16:41 ` Avi Kivity
[not found] ` <46B0B7D0.9080203-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-08-01 19:45 ` Ulrich Schreiner
[not found] ` <46B0E2F0.1070701-sZDnKEZIvs8b1SvskN2V4Q@public.gmane.org>
2007-08-02 8:24 ` Avi Kivity
[not found] ` <46B194C5.5040508-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-08-02 19:31 ` Ulrich Schreiner
2007-08-07 7:20 ` Ulrich Schreiner
2007-08-07 7:44 ` Dor Laor
[not found] ` <64F9B87B6B770947A9F8391472E032160D17A0EA-yEcIvxbTEBqsx+V+t5oei8rau4O3wl8o3fe8/T/H7NteoWH0uzbU5w@public.gmane.org>
2007-08-07 9:43 ` Ulrich Schreiner
2007-08-07 11:32 ` Luca
2007-08-07 11:51 ` Dor Laor
[not found] ` <64F9B87B6B770947A9F8391472E032160D17A197-yEcIvxbTEBqsx+V+t5oei8rau4O3wl8o3fe8/T/H7NteoWH0uzbU5w@public.gmane.org>
2007-08-07 12:08 ` Luca
[not found] ` <68676e00708070508w3d9e5ab8gd26263c44bf59f0d-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-08-07 12:30 ` Dor Laor
[not found] ` <64F9B87B6B770947A9F8391472E032160D17A1C2-yEcIvxbTEBqsx+V+t5oei8rau4O3wl8o3fe8/T/H7NteoWH0uzbU5w@public.gmane.org>
2007-08-07 12:50 ` Ulrich Schreiner
2007-08-07 14:38 ` Dong, Eddie
[not found] ` <10EA09EFD8728347A513008B6B0DA77A01E45A1D-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-08-07 14:50 ` Dor Laor
2007-08-07 20:49 ` Luca Tettamanti [this message]
[not found] ` <20070807204922.GA27976-sTXFmx6KbOnUXq0IF5SVAZ4oGUkBHcCu@public.gmane.org>
2007-08-08 6:28 ` Ulrich Schreiner
2007-08-07 12:25 ` Ulrich Schreiner
2007-08-09 23:23 ` Matthew Kent
2007-08-10 0:09 ` Matthew Kent
2007-08-10 5:32 ` Ulrich Schreiner
2007-08-10 6:39 ` Ulrich Schreiner
2007-08-16 9:56 ` Avi Kivity
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=20070807204922.GA27976@dreamland.darkstar.lan \
--to=kronos.it-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=avik-atKUWr5tajBWk0Htik3J/w@public.gmane.org \
--cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
--cc=ulrich.schreiner-sZDnKEZIvs8b1SvskN2V4Q@public.gmane.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