99 lines
3.5 KiB
Diff
99 lines
3.5 KiB
Diff
From 3206001ad1b42cf6fb97c7848f438d2bdbe843bc Mon Sep 17 00:00:00 2001
|
|
From: Tomas Glozar <tglozar@redhat.com>
|
|
Date: Fri, 30 Jun 2023 11:19:02 +0200
|
|
Subject: [PATCH] rteval: Detect isolcpus in systopology
|
|
|
|
Works similarly to online_cpus:
|
|
- add CpuList.isolated_cpulist to filter isolated CPUs
|
|
- add SysTopology.isolated_cpus to get list of isolated CPUs
|
|
- add CpuList.nonisolated_cpulist to do the opposite filter
|
|
- add SysTopology.default_cpus to get CPUs that are used for scheduling
|
|
by default, i.e. online and non-isolated CPUs
|
|
|
|
Signed-off-by: Tomas Glozar <tglozar@redhat.com>
|
|
Signed-off-by: John Kacur <jkacur@redhat.com>
|
|
---
|
|
rteval/systopology.py | 47 +++++++++++++++++++++++++++++++++++++++++++
|
|
1 file changed, 47 insertions(+)
|
|
|
|
diff --git a/rteval/systopology.py b/rteval/systopology.py
|
|
index c8f85c5..19443f9 100644
|
|
--- a/rteval/systopology.py
|
|
+++ b/rteval/systopology.py
|
|
@@ -127,6 +127,11 @@ class CpuList:
|
|
return True
|
|
return False
|
|
|
|
+ @staticmethod
|
|
+ def isolated_file_exists():
|
|
+ """ Check whether machine / kernel is configured with isolated file """
|
|
+ return os.path.exists(os.path.join(CpuList.cpupath, "isolated"))
|
|
+
|
|
@staticmethod
|
|
def longest_sequence(cpulist):
|
|
""" return index of last element of a sequence that steps by one """
|
|
@@ -214,6 +219,24 @@ class CpuList:
|
|
newlist.append(cpu)
|
|
return newlist
|
|
|
|
+ @staticmethod
|
|
+ def isolated_cpulist(cpulist):
|
|
+ """Given a cpulist, return a cpulist of isolated CPUs"""
|
|
+ if not CpuList.isolated_file_exists():
|
|
+ return cpulist
|
|
+ isolated_cpulist = sysread(CpuList.cpupath, "isolated")
|
|
+ isolated_cpulist = CpuList.expand_cpulist(isolated_cpulist)
|
|
+ return list(set(isolated_cpulist) & set(cpulist))
|
|
+
|
|
+ @staticmethod
|
|
+ def nonisolated_cpulist(cpulist):
|
|
+ """Given a cpulist, return a cpulist of non-isolated CPUs"""
|
|
+ if not CpuList.isolated_file_exists():
|
|
+ return cpulist
|
|
+ isolated_cpulist = sysread(CpuList.cpupath, "isolated")
|
|
+ isolated_cpulist = CpuList.expand_cpulist(isolated_cpulist)
|
|
+ return list(set(cpulist).difference(set(isolated_cpulist)))
|
|
+
|
|
#
|
|
# class to abstract access to NUMA nodes in /sys filesystem
|
|
#
|
|
@@ -362,11 +385,35 @@ class SysTopology:
|
|
cpulist.sort()
|
|
return cpulist
|
|
|
|
+ def isolated_cpus(self):
|
|
+ """ return a list of integers of all isolated cpus """
|
|
+ cpulist = []
|
|
+ for n in self.nodes:
|
|
+ cpulist += CpuList.isolated_cpulist(self.getcpus(n))
|
|
+ cpulist.sort()
|
|
+ return cpulist
|
|
+
|
|
+ def default_cpus(self):
|
|
+ """ return a list of integers of all default schedulable cpus, i.e. online non-isolated cpus """
|
|
+ cpulist = []
|
|
+ for n in self.nodes:
|
|
+ cpulist += CpuList.nonisolated_cpulist(self.getcpus(n))
|
|
+ cpulist.sort()
|
|
+ return cpulist
|
|
+
|
|
def online_cpus_str(self):
|
|
""" return a list of strings of numbers of all online cpus """
|
|
cpulist = [str(cpu) for cpu in self.online_cpus()]
|
|
return cpulist
|
|
|
|
+ def isolated_cpus_str(self):
|
|
+ cpulist = [str(cpu) for cpu in self.isolated_cpus()]
|
|
+ return cpulist
|
|
+
|
|
+ def default_cpus_str(self):
|
|
+ cpulist = [str(cpu) for cpu in self.default_cpus()]
|
|
+ return cpulist
|
|
+
|
|
def invert_cpulist(self, cpulist):
|
|
""" return a list of online cpus not in cpulist """
|
|
return [c for c in self.online_cpus() if c not in cpulist]
|
|
--
|
|
2.41.0
|
|
|