-# $Id$
-# $URL$
-
"""Whole core scheduling
"""
import cgroups
glo_coresched_simulate = False
+joinpath = os.path.join
class CoreSched:
""" Whole-core scheduler
self.mems_map={}
self.cpu_siblings={}
- def get_cgroup_var(self, name=None, filename=None):
+ def get_cgroup_var(self, name=None, subsys=None, filename=None):
""" decode cpuset.cpus or cpuset.mems into a list of units that can
be reserved.
"""
if filename==None:
# filename="/dev/cgroup/" + name
- filename=cgroups.get_base_path() + name
+ filename = reduce(lambda a, b: joinpath(a, b) if b else a, [subsys, name],
+ cgroups.get_base_path())
+
data = open(filename).readline().strip()
if not data:
if self.cpus!=[]:
return self.cpus
- self.cpus = self.get_cgroup_var(self.cgroup_var_name)
+ self.cpus = self.get_cgroup_var(self.cgroup_var_name, 'cpuset')
self.cpu_siblings = {}
for item in self.cpus:
if self.mems!=[]:
return self.mems
- self.mems = self.get_cgroup_var(self.cgroup_mem_name)
+ self.mems = self.get_cgroup_var(self.cgroup_mem_name, 'cpuset')
# build a mapping from memory nodes to the cpus they can be used with
return []
siblings = []
- x = int(open(fn,"rt").readline().strip(),16)
+ x = open(fn, 'rt').readline().strip().split(',')[-1]
+ x = int(x, 16)
+
cpuid = 0
while (x>0):
if (x&1)!=0: