<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:"HP Simplified";
        panose-1:2 11 6 4 2 2 4 2 2 4;}
@font-face
        {font-family:"YaHei Consolas Hybrid";
        panose-1:2 11 5 9 2 2 4 2 2 4;}
@font-face
        {font-family:"\@YaHei Consolas Hybrid";
        panose-1:2 11 5 9 2 2 4 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        text-align:justify;
        text-justify:inter-ideograph;
        font-size:10.5pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"HP Simplified","sans-serif";
        color:windowtext;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"HP Simplified","sans-serif";
        color:#7030A0;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="ZH-CN" link="#0563C1" vlink="#954F72" style="text-justify-trim:punctuation">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;;color:#7030A0">Hi All,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;;color:#7030A0"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;;color:#7030A0">Any feedback for this topic?
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;;color:#7030A0">Add Doron and Martin in the mail list.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;;color:#7030A0"><o:p>&nbsp;</o:p></span></p>
<div>
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:9.0pt;font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;;color:black">Best Regards,<br>
</span></b><span lang="EN-US" style="font-size:9.0pt;font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;;color:#717172">Jason Liao</span><span lang="EN-US" style="color:#7030A0"><o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;;color:#7030A0"><o:p>&nbsp;</o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" align="left" style="text-align:left"><b><span lang="EN-US" style="font-size:11.0pt">From:</span></b><span lang="EN-US" style="font-size:11.0pt"> vdsm-devel-bounces@lists.fedorahosted.org [mailto:vdsm-devel-bounces@lists.fedorahosted.org]
<b>On Behalf Of </b>Liao, Chuan (Jason Liao, HPservers-Core-OE-PSC)<br>
<b>Sent:</b> 2014</span><span style="font-size:11.0pt;font-family:SimSun">Äê</span><span lang="EN-US" style="font-size:11.0pt">3</span><span style="font-size:11.0pt;font-family:SimSun">ÔÂ</span><span lang="EN-US" style="font-size:11.0pt">11</span><span style="font-size:11.0pt;font-family:SimSun">ÈÕ</span><span lang="EN-US" style="font-size:11.0pt">
 14:02<br>
<b>To:</b> vdsm-devel; engine-devel@ovirt.org<br>
<b>Cc:</b> Liang, Shang-Chun (David Liang, HPservers-Core-OE-PSC); Vinod, Chegu; Gilad Chaplik<br>
<b>Subject:</b> [vdsm] Consider iowait add into usage CPU percentage<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal" align="left" style="text-align:left"><span lang="EN-US"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">Hi All,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">On engine core, The usage CPU percentage is calculated by %sys &#43; %usr<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">class VdsBrokerObjectsBuilder
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">function updateVDSStatisticsData<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:21.0pt;text-indent:21.0pt"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">vds.setCpuSys(AssignDoubleValue(xmlRpcStruct, VdsProperties.cpu_sys));<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vds.setCpuUser(AssignDoubleValue(xmlRpcStruct, VdsProperties.cpu_user));<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (vds.getCpuSys() != null &amp;&amp; vds.getCpuUser() != null) {<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vds.setUsageCpuPercent((int) (vds.getCpuSys() &#43; vds.getCpuUser()));<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">On vdsm, The %sys, %usr and %idle is calculated like below workflow,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">class API<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">function getStats<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:21.0pt;text-indent:21.0pt"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">decStats = self._cif._hostStats.get()<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">class clientIF<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">function __init__<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self._hostStats = sampling.HostStatsThread(log=log)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self._hostStats.start()<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">class HostStatsThread<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">function get<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hs0, hs1 = self._samples[0], self._samples[-1]<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ¡­<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; jiffies = (hs1.totcpu.user - hs0.totcpu.user) % (2 ** 32)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stats['cpuUser'] = jiffies / interval / self._ncpus<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; jiffies = (hs1.totcpu.sys - hs0.totcpu.sys) % (2 ** 32)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stats['cpuSys'] = jiffies / interval / self._ncpus<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stats['cpuIdle'] = max(0.0, 100.0 - stats['cpuUser'] - stats['cpuSys'])<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">class HostSample<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">function __init__<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.totcpu = TotalCpuSample()<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">class TotalCpuSample<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">function __init__<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.user, userNice, self.sys, self.idle = \<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; map(int, file('/proc/stat').readline().split()[1:5])<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.user &#43;= userNice<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">Question1: Why stats[¡®cpuIdle¡¯] do not use the sampling data totcpu.idle for calculating?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;">Question2: There is another data named iowait in /proc/stat, do we need to consider add this into usage CPU percentage for calculating?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:9.0pt;font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;;color:black">Best Regards,<br>
</span></b><span lang="EN-US" style="font-size:9.0pt;font-family:&quot;HP Simplified&quot;,&quot;sans-serif&quot;;color:#717172">Jason Liao</span><span lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p>&nbsp;</o:p></span></p>
</div>
</body>
</html>