Hi All,

Any feedback for this topic?
Add Doron and Martin in the mail list.

Best Regards,
Jason Liao

From: vdsm-devel-boun...@lists.fedorahosted.org 
[mailto:vdsm-devel-boun...@lists.fedorahosted.org] On Behalf Of Liao, Chuan 
(Jason Liao, HPservers-Core-OE-PSC)
Sent: 2014年3月11日 14:02
To: vdsm-devel; engine-de...@ovirt.org
Cc: Liang, Shang-Chun (David Liang, HPservers-Core-OE-PSC); Vinod, Chegu; Gilad 
Chaplik
Subject: [vdsm] Consider iowait add into usage CPU percentage

Hi All,

On engine core, The usage CPU percentage is calculated by %sys + %usr

class VdsBrokerObjectsBuilder
function updateVDSStatisticsData
vds.setCpuSys(AssignDoubleValue(xmlRpcStruct, VdsProperties.cpu_sys));
        vds.setCpuUser(AssignDoubleValue(xmlRpcStruct, VdsProperties.cpu_user));
        if (vds.getCpuSys() != null && vds.getCpuUser() != null) {
            vds.setUsageCpuPercent((int) (vds.getCpuSys() + vds.getCpuUser()));
        }

On vdsm, The %sys, %usr and %idle is calculated like below workflow,

class API
function getStats
decStats = self._cif._hostStats.get()
class clientIF
function __init__
                   self._hostStats = sampling.HostStatsThread(log=log)
        self._hostStats.start()
class HostStatsThread
function get
                   hs0, hs1 = self._samples[0], self._samples[-1]
                   …
                   jiffies = (hs1.totcpu.user - hs0.totcpu.user) % (2 ** 32)
        stats['cpuUser'] = jiffies / interval / self._ncpus
        jiffies = (hs1.totcpu.sys - hs0.totcpu.sys) % (2 ** 32)
        stats['cpuSys'] = jiffies / interval / self._ncpus
        stats['cpuIdle'] = max(0.0, 100.0 - stats['cpuUser'] - stats['cpuSys'])
class HostSample
function __init__
                   self.totcpu = TotalCpuSample()
class TotalCpuSample
function __init__
         self.user, userNice, self.sys, self.idle = \
            map(int, file('/proc/stat').readline().split()[1:5])
        self.user += userNice

Question1: Why stats[‘cpuIdle’] do not use the sampling data totcpu.idle for 
calculating?

Question2: There is another data named iowait in /proc/stat, do we need to 
consider add this into usage CPU percentage for calculating?

Best Regards,
Jason Liao

_______________________________________________
vdsm-devel mailing list
vdsm-devel@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-devel

Reply via email to