Dan Kenigsberg has submitted this change and it was merged.
Change subject: sampling: use constants for counter bounds
......................................................................
sampling: use constants for counter bounds
When we report cpu and network usage, we take two samples of Linux
counters, and divide their difference by the elapsed time. If a sampled
counter wraps around its upper bound, we might report an invalid
negative value. To avoid that, we take the modulu of the difference.
For example, assume that the first sample was (2**64 - 10) jiffies and
30 jiffies have passed until the second sample, the difference would be
the hugely negative value (30 - 2**64). Taking modulu 2**64 returns the
correct value of 30 jiffies.
JIFFIES_BOUND is taken from the size of clock_t and NETSTATS_BOUND -
from the size of the fields of struct net_device_stats. I am not aware
of any programmatic way to acquire this value, but they are both of 64
bit size on x86_64 and ppc64.
Taking modulu 2**32 works perfectly well, since two subsequent samples
are unlikly to be that far apart, and it has the benefit of working well
on a 32 bit host, too.
Change-Id: I706000106c3bc31edf8541c980bce1f49464ebf8
Signed-off-by: Dan Kenigsberg <danken(a)redhat.com>
Reviewed-on:
https://gerrit.ovirt.org/24194
Reviewed-by: Nir Soffer <nsoffer(a)redhat.com>
Tested-by: Francesco Romani <fromani(a)redhat.com>
---
M vdsm/virt/sampling.py
1 file changed, 12 insertions(+), 9 deletions(-)
Approvals:
Nir Soffer: Looks good to me, but someone else must approve
Dan Kenigsberg: Looks good to me, approved; Passed CI tests
Francesco Romani: Verified
--
To view, visit
https://gerrit.ovirt.org/24194
To unsubscribe, visit
https://gerrit.ovirt.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I706000106c3bc31edf8541c980bce1f49464ebf8
Gerrit-PatchSet: 6
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Antoni Segura Puimedon <toni+ovirt(a)midokura.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Federico Simoncelli <fsimonce(a)redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani(a)redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer(a)redhat.com>
Gerrit-Reviewer: automation(a)ovirt.org