Change in vdsm[master]: Instead of PAGE_SIZE_BYTES use os.sysconf('SC_PAGESIZE')

ybronhei at redhat.com ybronhei at redhat.com
Mon Feb 29 10:52:07 UTC 2016


Yaniv Bronhaim has uploaded a new change for review.

Change subject: Instead of PAGE_SIZE_BYTES use os.sysconf('SC_PAGESIZE')
......................................................................

Instead of PAGE_SIZE_BYTES use os.sysconf('SC_PAGESIZE')

PAGE_SIZE_BYTES constant does not help in any way and cause modules to
import caps

Change-Id: I7ca893f4cfb14c67788d96a0ced96e6325f0d0c5
Signed-off-by: Yaniv Bronhaim <ybronhei at redhat.com>
---
M tests/momTests.py
M vdsm/API.py
M vdsm/caps.py
M vdsm/momIF.py
4 files changed, 6 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/55/54155/1

diff --git a/tests/momTests.py b/tests/momTests.py
index bf11a84..76f68e2 100644
--- a/tests/momTests.py
+++ b/tests/momTests.py
@@ -21,11 +21,10 @@
 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 os
 import monkeypatch
 
 MOM_CONF = "/dev/null"
@@ -160,7 +159,7 @@
             "ksmMergeAcrossNodes": True,
             "ksmState": False,
             "ksmPages": 5,
-            "memShared": 100 * PAGE_SIZE_BYTES / Mbytes
+            "memShared": 100 * os.sysconf('SC_PAGESIZE') / Mbytes
         }
 
         self.assertEqual(stats, expected)
diff --git a/vdsm/API.py b/vdsm/API.py
index 479c00b..1136fe2 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -57,7 +57,6 @@
 import caps
 from vdsm.config import config
 import hostdev
-from caps import PAGE_SIZE_BYTES
 
 
 haClient = None  # Define here to work around pyflakes issue #13
@@ -1675,7 +1674,7 @@
                     resident += int(statmfile.read().split()[1])
             except:
                 pass
-        resident *= PAGE_SIZE_BYTES
+        resident *= os.sysconf('SC_PAGESIZE')
         meminfo = utils.readMemInfo()
         freeOrCached = (meminfo['MemFree'] +
                         meminfo['Cached'] + meminfo['Buffers']) * Kbytes
diff --git a/vdsm/caps.py b/vdsm/caps.py
index 28e5e3c..64a377d 100644
--- a/vdsm/caps.py
+++ b/vdsm/caps.py
@@ -59,7 +59,6 @@
 except ImportError:
     pass
 
-PAGE_SIZE_BYTES = os.sysconf('SC_PAGESIZE')
 CPU_MAP_FILE = '/usr/share/libvirt/cpu_map.xml'
 
 try:
diff --git a/vdsm/momIF.py b/vdsm/momIF.py
index 0800af1..86326b5 100644
--- a/vdsm/momIF.py
+++ b/vdsm/momIF.py
@@ -19,9 +19,9 @@
 #
 
 import logging
+import os
 import socket
 from vdsm.config import config
-from caps import PAGE_SIZE_BYTES
 from vdsm.define import Mbytes
 
 try:
@@ -69,7 +69,8 @@
             ret['ksmState'] = bool(stats['ksm_run'])
             ret['ksmPages'] = stats['ksm_pages_to_scan']
             ret['ksmMergeAcrossNodes'] = bool(stats['ksm_merge_across_nodes'])
-            ret['memShared'] = stats['ksm_pages_sharing'] * PAGE_SIZE_BYTES
+            ret['memShared'] = stats['ksm_pages_sharing'] * \
+                os.sysconf('SC_PAGESIZE')
             ret['memShared'] /= Mbytes
             ret['ksmCpu'] = stats['ksmd_cpu_usage']
         except (AttributeError, socket.error):


-- 
To view, visit https://gerrit.ovirt.org/54155
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7ca893f4cfb14c67788d96a0ced96e6325f0d0c5
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yaniv Bronhaim <ybronhei at redhat.com>


More information about the vdsm-patches mailing list