WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] How does xentop.c code gets previous sample to calculate CPU

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] How does xentop.c code gets previous sample to calculate CPU utilization ?
From: Mahendra Kutare <mahendra.kutare@xxxxxxxxx>
Date: Wed, 24 Nov 2010 10:41:07 -0500
Delivery-date: Wed, 24 Nov 2010 07:42:36 -0800
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:from:date :message-id:subject:to:content-type; bh=NqBP5iBZj0ntzBJgtBRzwGQPpupYkpO2sri5aD/la7w=; b=JxNFPqmJHrI6sQGSUPLD7xIOb6KjOjEU3gofNA03clAKCaxoKjoTkzr7egjEZAweMn 0lz5xGaag2J+0a4fIQs1RWCsOaIgTi5etzQHdWwvCqMj6dUQlrbzSRgBQerqwGWvrqoC 0pw+stkfKcDcOB/NDdcKnarNmzb9FmV9PaBM4=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=A6kyZTweBMVa2yOqhH3Uif9OQx/MajelKHj0gSyF5oIsoS5Vfo4pNgZ8HDBDTLN/Eu Ioq2AZaZ+TIg9jqRFLcHdOo4CkLhfm2LPfHJsIqu/9qL1XRMb3bjwQ4S/CF49lXKLIrU lz2EZFYZAmWWH1nvMXEqEhzvApnpy6306nLPw=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Hi,

I am creating my sample code which takes most of the cpu utilization code from xentop.c under tools/xenstat/ for cpu and memory utilization calculation.

I see somehow the cpu utilization always shows zero because it always sees prev_node as zero of the following -

475 /* Computes the CPU percentage used for a specified domain */
 476 static double get_cpu_pct(xenstat_domain *domain)
 477 {                                    
 478     xenstat_domain *old_domain;      
 479     double us_elapsed;               
 480                                      
 481     /* Can't calculate CPU percentage without a previous sample. */
 482     if(prev_node == NULL)            
 483         return 0.0;                  
 484                                      
 485     old_domain = xenstat_node_domain(prev_node, xenstat_domain_id(domain));                                                                             
 486     if(old_domain == NULL)           
 487         return 0.0;                  
 488                                      
 489     /* Calculate the time elapsed in microseconds */
 490     us_elapsed = ((curtime.tv_sec-oldtime.tv_sec)*1000000.0
 491               +(curtime.tv_usec - oldtime.tv_usec));
 492                                      
 493     /* In the following, nanoseconds must be multiplied by 1000.0 to
 494      * convert to microseconds, then divided by 100.0 to get a percentage,
 495      * resulting in a multiplication by 10.0 */
 496     return ((xenstat_domain_cpu_ns(domain)
 497          -xenstat_domain_cpu_ns(old_domain))/10.0)/us_elapsed;
 498 }                                    

I have looked around in tools/xenstats/xentop.c code and have used the same functions with same code. But somehow I am missing something here. It is clearly mentioned in above code on line 481 that it requires previous samples and somehow in my code I am not supplying that and xentop is doing it.

I am trying to figure out how does xentop.c provides the previous sample for CPU utilization...so that I can do the same in my code but no luck so far after I have looked and used the same code.

Any pointers would be useful ?

Thanks
Mahendra


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] How does xentop.c code gets previous sample to calculate CPU utilization ?, Mahendra Kutare <=