Message ID | 20210909130314.6109-3-jkacur@redhat.com |
---|---|
State | New |
Headers | show |
Series | [1/3] rteval: Only process warnings if dmidecode_loaded is True | expand |
John Kacur <jkacur@redhat.com> writes: > From: Punit Agrawal <punit1.agrawal@toshiba.co.jp> > > Certain systems such as Arm v7 do not have support for Numa nodes, > i.e., "/sys/devices/system/node*" does not exist. Instead of erroring > out in this situation, it would be better if rteval could use > alternate sources to get the system topology and memory information. > > Introduce the notion of a fake Numa node (as a class) which is used > when no numa nodes are found on the system. Other than the > constructor, it provides the same interface as the existing NumaNode > class so existing users should work without any changes. > > Signed-off-by: Punit Agrawal <punit1.agrawal@toshiba.co.jp> > - Renamed Fake to Sim for simulated > Signed-off-by: John Kacur <jkacur@redhat.com> > --- > rteval/systopology.py | 37 +++++++++++++++++++++++++++++++------ > 1 file changed, 31 insertions(+), 6 deletions(-) > > diff --git a/rteval/systopology.py b/rteval/systopology.py > index c61ec1a58514..3c996048f8c1 100644 > --- a/rteval/systopology.py > +++ b/rteval/systopology.py > @@ -191,6 +191,30 @@ class NumaNode: > """ return list of cpus for this node """ > return self.cpus.getcpulist() > > +class SimNumaNode(NumaNode): > + """class representing a simulated NUMA node. > + For systems which don't have NUMA enabled (no > + /sys/devices/system/node) such as Arm v7 > + """ > + > + cpupath = '/sys/devices/system/cpu' > + mempath = '/proc/meminfo' > + > + def __init__(self): > + self.nodeid = 0 > + self.cpus = CpuList(sysread(SimNumaNode.cpupath, "possible")) > + self.getmeminfo() > + > + def getmeminfo(self): > + self.meminfo = {} > + for l in open(SimNumaNode.mempath, "r"): > + elements = l.split() > + key = elements[0][0:-1] > + val = int(elements[1]) > + if len(elements) == 3 and elements[2] == "kB": > + val *= 1024 > + self.meminfo[key] = val > + > # > # Class to abstract the system topology of numa nodes and cpus > # > @@ -238,12 +262,13 @@ class SysTopology: > > def getinfo(self): > nodes = glob.glob(os.path.join(SysTopology.nodepath, 'node[0-9]*')) > - if not nodes: > - raise RuntimeError("No valid nodes found in %s!" % SysTopology.nodepath) > - nodes.sort() > - for n in nodes: > - node = int(os.path.basename(n)[4:]) > - self.nodes[node] = NumaNode(n) > + if nodes: > + nodes.sort() > + for n in nodes: > + node = int(os.path.basename(n)[4:]) > + self.nodes[node] = NumaNode(n) > + else: > + self.nodes[0] = SimNumaNode() > > def getnodes(self): > return list(self.nodes.keys()) The name changes look good and passed a test run of rteval on a system with no numa nodes. Thanks, Punit
diff --git a/rteval/systopology.py b/rteval/systopology.py index c61ec1a58514..3c996048f8c1 100644 --- a/rteval/systopology.py +++ b/rteval/systopology.py @@ -191,6 +191,30 @@ class NumaNode: """ return list of cpus for this node """ return self.cpus.getcpulist() +class SimNumaNode(NumaNode): + """class representing a simulated NUMA node. + For systems which don't have NUMA enabled (no + /sys/devices/system/node) such as Arm v7 + """ + + cpupath = '/sys/devices/system/cpu' + mempath = '/proc/meminfo' + + def __init__(self): + self.nodeid = 0 + self.cpus = CpuList(sysread(SimNumaNode.cpupath, "possible")) + self.getmeminfo() + + def getmeminfo(self): + self.meminfo = {} + for l in open(SimNumaNode.mempath, "r"): + elements = l.split() + key = elements[0][0:-1] + val = int(elements[1]) + if len(elements) == 3 and elements[2] == "kB": + val *= 1024 + self.meminfo[key] = val + # # Class to abstract the system topology of numa nodes and cpus # @@ -238,12 +262,13 @@ class SysTopology: def getinfo(self): nodes = glob.glob(os.path.join(SysTopology.nodepath, 'node[0-9]*')) - if not nodes: - raise RuntimeError("No valid nodes found in %s!" % SysTopology.nodepath) - nodes.sort() - for n in nodes: - node = int(os.path.basename(n)[4:]) - self.nodes[node] = NumaNode(n) + if nodes: + nodes.sort() + for n in nodes: + node = int(os.path.basename(n)[4:]) + self.nodes[node] = NumaNode(n) + else: + self.nodes[0] = SimNumaNode() def getnodes(self): return list(self.nodes.keys())