summaryrefslogtreecommitdiffstats
path: root/rteval
diff options
context:
space:
mode:
authorDavid Sommerseth <davids@redhat.com>2010-08-10 09:15:29 +0200
committerDavid Sommerseth <davids@redhat.com>2010-08-10 09:15:29 +0200
commitdfc1b0627ea1d52d5a70c10bf03669665e5c99f5 (patch)
treed110443eaffccd689a80e0a9296c134571fedfd5 /rteval
parent41a8faee05f1737bc6fcaf8cf26b2a9e033de6eb (diff)
downloadrteval-dfc1b0627ea1d52d5a70c10bf03669665e5c99f5.tar.gz
rteval-dfc1b0627ea1d52d5a70c10bf03669665e5c99f5.tar.xz
rteval-dfc1b0627ea1d52d5a70c10bf03669665e5c99f5.zip
Improved CPU socket counting
Some computers start with physical_package_id=1, which would return two CPU sockets with the former CPU socket counting method. This is fixed by using a more failsafe method, by counting unique physical_package_id references. Signed-off-by: David Sommerseth <davids@redhat.com>
Diffstat (limited to 'rteval')
-rw-r--r--rteval/cputopology.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/rteval/cputopology.py b/rteval/cputopology.py
index 4b696f7..14631eb 100644
--- a/rteval/cputopology.py
+++ b/rteval/cputopology.py
@@ -51,6 +51,7 @@ class CPUtopology:
self.__cputop_n = libxml2.newNode('cpu_topology')
+ cpusockets = []
for dirname in os.listdir(self.sysdir):
# Only parse directories which starts with 'cpu'
if (dirname.find('cpu', 0) == 0) and os.path.isdir(os.path.join(self.sysdir, dirname)):
@@ -79,10 +80,19 @@ class CPUtopology:
phys_pkg_id = self.__read(os.path.join(dirname, 'topology'),
'physical_package_id')
cpu_n.newProp('physical_package_id', str(phys_pkg_id))
- if phys_pkg_id > (self.__cpu_sockets - 1):
- self.__cpu_sockets = phys_pkg_id + 1
+ cpusockets.append(phys_pkg_id)
break;
+ # Count unique CPU sockets
+ lastsock = None
+ sockcnt = 0
+ cpusockets.sort()
+ for sck in cpusockets:
+ if sck != lastsock:
+ lastsock = sck
+ sockcnt += 1
+ self.__cpu_sockets = sockcnt
+
# Summarise the core counts
self.__cputop_n.newProp('num_cpu_cores', str(self.__cpu_cores))
self.__cputop_n.newProp('num_cpu_cores_online', str(self.__online_cores))
@@ -115,8 +125,10 @@ def unit_test(rootdir):
cputop.getCPUsockets())
return 0
except Exception, e:
+ # import traceback
+ # traceback.print_exc(file=sys.stdout)
print "** EXCEPTION %s", str(e)
return 1
if __name__ == '__main__':
- unit_test()
+ unit_test(None)