[Engine-devel] Consider iowait add into usage CPU percentage

Doron Fediuck dfediuck at redhat.com
Wed Mar 12 02:40:11 UTC 2014



----- Original Message -----
> From: "Chuan Liao (Jason Liao, HPservers-Core-OE-PSC)" <chuan.liao at hp.com>
> To: "vdsm-devel" <vdsm-devel at lists.fedorahosted.org>, engine-devel at ovirt.org
> Cc: "Chegu Vinod" <chegu_vinod at hp.com>, "Shang-Chun Liang (David Liang, HPservers-Core-OE-PSC)"
> <shangchun.liang at hp.com>
> Sent: Wednesday, March 12, 2014 4:09:59 AM
> Subject: Re: [Engine-devel] Consider iowait add into usage CPU percentage
> 
> 
> 
> Hi All,
> 
> 
> 
> Any feedback for this topic?
> 
> Add Doron and Martin in the mail list.
> 
> 
> 
> 
> Best Regards,
> Jason Liao
> 
> 
> 
> 
> 
> From: vdsm-devel-bounces at lists.fedorahosted.org
> [mailto:vdsm-devel-bounces at lists.fedorahosted.org] On Behalf Of Liao, Chuan
> (Jason Liao, HPservers-Core-OE-PSC)
> Sent: 2014 年 3 月 11 日 14:02
> To: vdsm-devel; engine-devel at 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?
> 
I have a vague memory of this calculation which tries to level the numbers. 
ie- the assumption is that user and sys adds up to something which is less than 100.
If this is not the case (multiple core / SMT) idle will be set to 0.
But possibly Dan remembers something else?

> 
> 
> Question2: There is another data named iowait in /proc/stat, do we need to
> consider add this into usage CPU percentage for calculating?
> 
Since the above excludes iowait, I wouldn't add it here. Otherwise
we may have inconsistency with the numbers.

> 
> 
> Best Regards,
> Jason Liao
> 
> 
> 
> _______________________________________________
> Engine-devel mailing list
> Engine-devel at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/engine-devel
> 



More information about the Devel mailing list