From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gaurav Dhiman Subject: Re: Estimating CPU utilization of DomU Date: Fri, 16 Jul 2010 16:28:04 -0700 Message-ID: References: <20100716081918.B9D41180A2@m021.s.css.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <20100716081918.B9D41180A2@m021.s.css.fujitsu.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Atsushi SAKAI Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org On Fri, Jul 16, 2010 at 1:19 AM, Atsushi SAKAI wrot= e: > Hi Guarav > > =A0You should test by xentop, instead of libvirt. > Also you should write which kernel you are using. > Thanks for your reply. I will test with xentop as well. But what is wrong with libvirt? Ultimately both of them use Xen APIs, right? I am using Linux 2.6.30 pv_ops kernel as my Dom0, and Linux 2.6.18-xen kernel (from the Xen website) as my DomU. Thanks, -Gaurav > Gaurav Dhiman wrote: > >> Hi All, >> >> I am trying to implement a small script to estimate the CPU >> utilization of my DomU's from Domain-0 using libvirt APIs. I am using >> the virDomainInfo structure for that: >> >> struct virDomainInfo{ >> unsigned char state =A0 : the running state, one of virDomainState >> unsigned long maxMem =A0: the maximum memory in KBytes allowed >> unsigned long memory =A0: the memory in KBytes used by the domain >> unsigned short =A0 =A0 =A0 =A0nrVirtCpu =A0 =A0 =A0 : the number of virt= ual CPUs for the domain >> unsigned long long =A0 =A0cpuTime : the CPU time used in nanoseconds >> } >> >> So basically I query this structure for my DomU's every 'n' seconds, >> and get the CPU utilization by taking the difference of cpuTime (in >> seconds) and diving it by 'n'. To verify my estimates, I am running >> sar inside my DomU's (I do 100-%idle to estimate CPU util). It works >> perfectly for CPU intensive DomU's, but I observe some discrepancies >> for I/O intensive DomU's. My scripts shows higher CPU utilization than >> the sar output. Sometimes the difference is close to 10-15%. I am not >> sure what is the reason for this? Is there some time which the DomU >> VCPUs spend running, which sar cannot see? Or does the libvirt API add >> up the time spent by domain-0 for work done on behalf of DomU to its >> structure? >> >> Any insights here would be really helpful! >> >> Thanks, >> -Gaurav >> >> _______________________________________________ >> Xen-devel mailing list >> Xen-devel@lists.xensource.com >> http://lists.xensource.com/xen-devel > > >