Martin Polednik has uploaded a new change for review. Change subject: cpuarch: Move PAGE_SIZE_BYTES to cpuarch ......................................................................
cpuarch: Move PAGE_SIZE_BYTES to cpuarch This constant is mostly related to the CPU architecture. Change-Id: Id36da115083b94f5c4c24b2af066e70caf09a17b Signed-off-by: Martin Polednik <mpoled...@redhat.com> --- M lib/vdsm/cpuarch.py M lib/vdsm/health.py M tests/momTests.py M vdsm/API.py M vdsm/caps.py M vdsm/momIF.py 6 files changed, 12 insertions(+), 9 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/90/54990/1 diff --git a/lib/vdsm/cpuarch.py b/lib/vdsm/cpuarch.py index bbb1332..387e7e3 100644 --- a/lib/vdsm/cpuarch.py +++ b/lib/vdsm/cpuarch.py @@ -20,6 +20,7 @@ from __future__ import absolute_import +import os import platform from .config import config @@ -31,6 +32,8 @@ SUPPORTED_ARCHITECTURES = (X86_64, PPC64, PPC64LE) +PAGE_SIZE_BYTES = os.sysconf('SC_PAGESIZE') + class UnsupportedArchitecture(Exception): def __init__(self, target_arch): diff --git a/lib/vdsm/health.py b/lib/vdsm/health.py index 1b414a5..8e50a7f 100644 --- a/lib/vdsm/health.py +++ b/lib/vdsm/health.py @@ -26,6 +26,7 @@ from . config import config from . import concurrent +from . import cpuarch _monitor = None @@ -114,7 +115,6 @@ class ProcStat(object): - _PAGE_SIZE = os.sysconf("SC_PAGESIZE") _TICKS_PER_SEC = os.sysconf("SC_CLK_TCK") _PATH = "/proc/self/stat" @@ -125,7 +125,7 @@ self.utime = int(fields[13], 10) / float(self._TICKS_PER_SEC) self.stime = int(fields[14], 10) / float(self._TICKS_PER_SEC) self.threads = int(fields[19], 10) - self.rss = int(fields[23], 10) * self._PAGE_SIZE / 1024 + self.rss = int(fields[23], 10) * cpuarch.PAGE_SIZE_BYTES / 1024 def saferepr(obj): diff --git a/tests/momTests.py b/tests/momTests.py index bf11a84..b5b512c 100644 --- a/tests/momTests.py +++ b/tests/momTests.py @@ -21,12 +21,13 @@ import logging import threading from momIF import MomClient -from caps import PAGE_SIZE_BYTES from vdsm.define import Mbytes from mom import unixrpc from six.moves import configparser import os.path import monkeypatch + +from vdsm import cpuarch MOM_CONF = "/dev/null" MOM_PORT = os.path.join(os.path.dirname(__file__), "test_mom_vdsm.sock") @@ -160,7 +161,7 @@ "ksmMergeAcrossNodes": True, "ksmState": False, "ksmPages": 5, - "memShared": 100 * PAGE_SIZE_BYTES / Mbytes + "memShared": 100 * cpuarch.PAGE_SIZE_BYTES / Mbytes } self.assertEqual(stats, expected) diff --git a/vdsm/API.py b/vdsm/API.py index 077d875..f905fb4 100644 --- a/vdsm/API.py +++ b/vdsm/API.py @@ -28,6 +28,7 @@ from vdsm.network.errors import ConfigNetworkError from vdsm import commands +from vdsm import cpuarch from vdsm import utils from clientIF import clientIF from vdsm import constants @@ -53,7 +54,6 @@ from vdsm.define import doneCode, errCode, Kbytes, Mbytes import caps from vdsm.config import config -from caps import PAGE_SIZE_BYTES haClient = None # Define here to work around pyflakes issue #13 @@ -1606,7 +1606,7 @@ resident += int(statmfile.read().split()[1]) except: pass - resident *= PAGE_SIZE_BYTES + resident *= cpuarch.PAGE_SIZE_BYTES meminfo = utils.readMemInfo() freeOrCached = (meminfo['MemFree'] + meminfo['Cached'] + meminfo['Buffers']) * Kbytes diff --git a/vdsm/caps.py b/vdsm/caps.py index 539deb3..899b25e 100644 --- a/vdsm/caps.py +++ b/vdsm/caps.py @@ -46,8 +46,6 @@ RNG_SOURCES = {'random': '/dev/random', 'hwrng': '/dev/hwrng'} -PAGE_SIZE_BYTES = os.sysconf('SC_PAGESIZE') - def _getFreshCapsXMLStr(): return libvirtconnection.get().getCapabilities() diff --git a/vdsm/momIF.py b/vdsm/momIF.py index 0800af1..a5523ce 100644 --- a/vdsm/momIF.py +++ b/vdsm/momIF.py @@ -21,9 +21,10 @@ import logging import socket from vdsm.config import config -from caps import PAGE_SIZE_BYTES from vdsm.define import Mbytes +from vdsm.cpuarch import PAGE_SIZE_BYTES + try: import mom from mom import unixrpc -- To view, visit https://gerrit.ovirt.org/54990 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id36da115083b94f5c4c24b2af066e70caf09a17b Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Martin Polednik <mpoled...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches