From mboxrd@z Thu Jan 1 00:00:00 1970 From: "David S. Ahern" Subject: gettimeofday "slow" in RHEL4 guests Date: Mon, 24 Nov 2008 10:47:24 -0700 Message-ID: <492AE8AC.2090502@cisco.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit To: kvm-devel Return-path: Received: from sj-iport-6.cisco.com ([171.71.176.117]:61749 "EHLO sj-iport-6.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752847AbYKXRr0 (ORCPT ); Mon, 24 Nov 2008 12:47:26 -0500 Received: from sj-core-2.cisco.com (sj-core-2.cisco.com [171.71.177.254]) by sj-dkim-4.cisco.com (8.12.11/8.12.11) with ESMTP id mAOHlQ4N008723 for ; Mon, 24 Nov 2008 09:47:26 -0800 Received: from xbh-sjc-211.amer.cisco.com (xbh-sjc-211.cisco.com [171.70.151.144]) by sj-core-2.cisco.com (8.13.8/8.13.8) with ESMTP id mAOHlQWl000471 for ; Mon, 24 Nov 2008 17:47:26 GMT Sender: kvm-owner@vger.kernel.org List-ID: 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 #include #include 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; }