pretty-printed
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Fri, 13 Mar 2015 14:23:45 +0000 (15:23 +0100)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Fri, 13 Mar 2015 14:23:53 +0000 (15:23 +0100)
coresched_lxc.py

index 1134eef..2aa81e7 100644 (file)
@@ -1,5 +1,5 @@
-"""Whole core scheduling
-
+"""
+Whole-core scheduling
 """
 
 import logger
@@ -11,16 +11,17 @@ glo_coresched_simulate = False
 joinpath = os.path.join
 
 class CoreSched:
-    """ Whole-core scheduler
+    """ 
+    Whole-core scheduler
 
-        The main entrypoint is adjustCores(self, slivers) which takes a
-        dictionary of sliver records. The cpu_cores field is pulled from the
-        effective rspec (rec["_rspec"]) for each sliver.
+    The main entrypoint is adjustCores(self, slivers) which takes a
+    dictionary of sliver records. The cpu_cores field is pulled from the
+    effective rspec (rec["_rspec"]) for each sliver.
 
-        If cpu_cores > 0 for a sliver, then that sliver will reserve one or
-        more of the cpu_cores on the machine.
+    If cpu_cores > 0 for a sliver, then that sliver will reserve one or
+    more of the cpu_cores on the machine.
 
-        One core is always left unreserved for system slices.
+    One core is always left unreserved for system slices.
     """
 
     def __init__(self, cgroup_var_name="cpuset.cpus", slice_attr_name="cpu_cores"):
@@ -33,8 +34,9 @@ class CoreSched:
         self.cpu_siblings={}
 
     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.
+        """ 
+        decode cpuset.cpus or cpuset.mems into a list of units that can
+        be reserved.
         """
 
         assert(filename!=None or name!=None)
@@ -65,7 +67,8 @@ class CoreSched:
         return units
 
     def get_cpus(self):
-        """ return a list of available cpu identifiers: [0,1,2,3...]
+        """ 
+        return a list of available cpu identifiers: [0,1,2,3...]
         """
 
         # the cpus never change, so if it's already been computed then don't
@@ -111,9 +114,10 @@ class CoreSched:
         return self.find_cpu_mostsiblings(cpus)
 
     def get_cgroups (self):
-        """ return a list of cgroups
-            this might change as vservers are instantiated, so always compute
-            it dynamically.
+        """ 
+        return a list of cgroups
+        this might change as vservers are instantiated, 
+        so always compute it dynamically.
         """
         return cgroups.get_cgroups()
         #cgroups = []
@@ -124,9 +128,10 @@ class CoreSched:
         #return cgroups
 
     def decodeCoreSpec (self, cores):
-        """ Decode the value of the core attribute. It's a number, followed by
-            an optional letter "b" to indicate besteffort cores should also
-            be supplied.
+        """ 
+        Decode the value of the core attribute. 
+        It's a number, followed by an optional letter "b" to indicate besteffort
+        cores should also be supplied.
         """
         bestEffort = False
 
@@ -142,9 +147,10 @@ class CoreSched:
         return (cores, bestEffort)
 
     def adjustCores (self, slivers):
-        """ slivers is a dict of {sliver_name: rec}
-                rec is a dict of attributes
-                    rec['_rspec'] is the effective rspec
+        """ 
+        slivers is a dict of {sliver_name: rec}
+           rec is a dict of attributes
+           rec['_rspec'] is the effective rspec
         """
 
         cpus = self.get_cpus()[:]
@@ -296,13 +302,15 @@ class CoreSched:
         pass
 
     def listToRange (self, list):
-        """ take a list of items [1,2,3,5,...] and return it as a range: "1-3,5"
-            for now, just comma-separate
+        """ 
+        take a list of items [1,2,3,5,...] and return it as a range: "1-3,5"
+        for now, just comma-separate
         """
         return ",".join( [str(i) for i in list] )
 
     def get_mems(self):
-        """ return a list of available cpu identifiers: [0,1,2,3...]
+        """ 
+        return a list of available cpu identifiers: [0,1,2,3...]
         """
 
         # the cpus never change, so if it's already been computed then don't
@@ -345,8 +353,9 @@ class CoreSched:
         return self.mems
 
     def find_associated_memnode(self, mems, cpu):
-        """ Given a list of memory nodes and a cpu, see if one of the nodes in
-            the list can be used with that cpu.
+        """ 
+        Given a list of memory nodes and a cpu, see if one of the nodes in
+        the list can be used with that cpu.
         """
         for item in mems:
             if cpu in self.mems_map[item]:
@@ -354,8 +363,8 @@ class CoreSched:
         return None
 
     def get_memnode_cpus(self, index):
-        """ for a given memory node, return the CPUs that it is associated
-            with.
+        """
+        for a given memory node, return the CPUs that it is associated with.
         """
         fn = "/sys/devices/system/node/node" + str(index) + "/cpulist"
         if not os.path.exists(fn):