From: "David S. Ahern" <daahern@cisco.com>
To: kvm-devel <kvm@vger.kernel.org>
Cc: Marcelo Tosatti <mtosatti@redhat.com>,
Glauber de Oliveira Costa <gcosta@redhat.com>,
Avi Kivity <avi@redhat.com>
Subject: Re: gettimeofday "slow" in RHEL4 guests
Date: Mon, 24 Nov 2008 21:41:40 -0700 [thread overview]
Message-ID: <492B8204.5@cisco.com> (raw)
In-Reply-To: <492AE8AC.2090502@cisco.com>
Some more data on this overhead.
RHEL3 (which is based on the 2.4.21 kernel) gets microsecond resolutions
by reading the TSC. Reading the TSC from within a guest is very fast on kvm.
RHEL4 (which is basd on the 2.6.9 kernel) allows multiple time sources:
pmtmr (ACPI power management timer which is the default), pit, hpet and TSC.
The pmtmr and pit both do ioport reads to get microsecond resolutions
(see read_pmtmr and get_offset_pit, respectively). For the tsc as the
timer source gettimeofday is *very* lightweight, but time drifts very
badly and ntpd cannot acquire a sync. I believe someone is working on
the HPET for guests and I know from bare metal performance that it is a
much lighter weight time source, but with RHEL4 the HPET breaks the
ability to use the RTC. So, I'm running out of options for reliable and
lightweight time sources.
Any chance the pit or pmtmr options can be optimized a bit?
thanks,
david
PS. yes, I did try the userspace pit and its performance is worse than
the in-kernel PIT.
David S. Ahern wrote:
> I noticed that gettimeofday in RHEL4.6 guests is taking much longer than
> with RHEL3.8 guests. I wrote a simple program (see below) to call
> gettimeofday in a loop 1,000,000 times and then used time to measure how
> long it took.
>
>
> For the RHEL3.8 guest:
> time -p ./timeofday_bench
> real 0.99
> user 0.12
> sys 0.24
>
> For the RHEL4.6 guest with the default clock source (pmtmr):
> time -p ./timeofday_bench
> real 15.65
> user 0.18
> sys 15.46
>
> and RHEL4.6 guest with PIT as the clock source (clock=pit kernel parameter):
> time -p ./timeofday_bench
> real 13.67
> user 0.21
> sys 13.45
>
> So, basically gettimeofday() takes about 50 times as long on a RHEL4 guest.
>
> Host is a DL380G5, 2 dual-core Xeon 5140 processors, 4 GB of RAM. It's
> running kvm.git tree as of 11/18/08 with kvm-75 userspace. Guest in both
> RHEL3 and RHEL4 cases has 4 vcpus, 3.5GB of RAM.
>
> david
>
> ----------
>
> timeofday_bench.c:
>
> #include <sys/time.h>
> #include <stdio.h>
> #include <stdlib.h>
>
> int main(int argc, char *argv[])
> {
> int rc = 0, n;
> struct timeval tv;
> int iter = 1000000; /* number of times to call gettimeofday */
>
> if (argc > 1)
> iter = atoi(argv[1]);
>
> if (iter == 0) {
> fprintf(stderr, "invalid number of iterations\n");
> return 1;
> }
>
> printf("starting.... ");
> for (n = 0; n < iter; ++n) {
> if (gettimeofday(&tv, NULL) != 0) {
> fprintf(stderr, "\ngettimeofday failed\n");
> rc = 1;
> break;
> }
> }
>
> if (!rc)
> printf("done\n");
>
> return rc;
> }
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2008-11-25 4:41 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-24 17:47 gettimeofday "slow" in RHEL4 guests David S. Ahern
2008-11-25 4:41 ` David S. Ahern [this message]
2008-11-25 10:14 ` Andi Kleen
2008-11-25 11:17 ` Alexander Graf
2008-11-25 11:48 ` Andi Kleen
2008-11-25 12:13 ` Alexander Graf
2008-11-25 12:52 ` Andi Kleen
2008-12-28 18:38 ` Marcelo Tosatti
2008-12-29 12:37 ` Yang, Sheng
2008-12-29 13:11 ` Avi Kivity
2008-12-29 16:12 ` Dor Laor
2008-12-29 16:27 ` Avi Kivity
2008-12-29 16:29 ` Avi Kivity
2008-11-25 17:20 ` Hollis Blanchard
2008-11-25 19:09 ` David S. Ahern
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=492B8204.5@cisco.com \
--to=daahern@cisco.com \
--cc=avi@redhat.com \
--cc=gcosta@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
/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.