rteval/SOURCES/rteval-use-systopology-for-...

79 lines
2.8 KiB
Diff

From c7ba86bae03dc98f3f988e0f261af1651930fd50 Mon Sep 17 00:00:00 2001
From: John Kacur <jkacur@redhat.com>
Date: Tue, 28 May 2019 23:47:22 +0200
Subject: [PATCH 2/2] rteval: Change hackbench to use systopology to calculate
online cpus
- change the class SysTopology method getcpus to work properly
. have hackbench make use of SysTopology instead of it's own
implementation to calculate cpus. The advantage is that this will
automatically calculate online cpus and sort them
Signed-off-by: John Kacur <jkacur@redhat.com>
---
rteval/modules/loads/hackbench.py | 18 +++++++++---------
rteval/systopology.py | 2 +-
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/rteval/modules/loads/hackbench.py b/rteval/modules/loads/hackbench.py
index 0ee60d900f18..b15ea6378310 100644
--- a/rteval/modules/loads/hackbench.py
+++ b/rteval/modules/loads/hackbench.py
@@ -30,6 +30,7 @@ from signal import SIGKILL
from rteval.modules.loads import CommandLineLoad
from rteval.Log import Log
from rteval.misc import expand_cpulist
+from rteval.systopology import SysTopology
class Hackbench(CommandLineLoad):
def __init__(self, config, logger):
@@ -53,24 +54,23 @@ class Hackbench(CommandLineLoad):
mult = 0
self._donotrun = True
- # figure out how many nodes we have
- self.nodes = [ n.split('/')[-1][4:] for n in glob.glob('/sys/devices/system/node/node*') ]
-
+ sysTop = SysTopology()
+ # get the number of nodes
+ self.nodes = sysTop.getnodes()
# get the cpus for each node
self.cpus = {}
biggest = 0
- for n in self.nodes:
- self.cpus[n] = [ int(c.split('/')[-1][3:]) for c in glob.glob('/sys/devices/system/node/node%s/cpu[0-9]*' % n) ]
- self.cpus[n].sort()
-
+ for n in sysTop:
+ self.cpus[n] = sysTop.getcpus(int(n))
# if a cpulist was specified, only allow cpus in that list on the node
if self.cpulist:
self.cpus[n] = [ c for c in self.cpus[n] if str(c) in expand_cpulist(self.cpulist) ]
# track largest number of cpus used on a node
- if len(self.cpus[n]) > biggest:
- biggest = len(self.cpus[n])
+ node_biggest = len(sysTop.getcpus(int(n)))
+ if node_biggest > biggest:
+ biggest = node_biggest
# remove nodes with no cpus available for running
for node,cpus in self.cpus.items():
diff --git a/rteval/systopology.py b/rteval/systopology.py
index 07674658df8e..9556e51d96a2 100644
--- a/rteval/systopology.py
+++ b/rteval/systopology.py
@@ -246,7 +246,7 @@ class SysTopology(object):
return list(self.nodes.keys())
def getcpus(self, node):
- return self.nodes[node]
+ return self.nodes[node].getcpulist()
--
2.20.1