git://git.onelab.eu
/
util-vserver-pl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4ca13a6
)
Use cgroup CPU scheduler
author
Andy Bavier
<acb@cs.princeton.edu>
Tue, 23 Jun 2009 14:51:59 +0000
(14:51 +0000)
committer
Andy Bavier
<acb@cs.princeton.edu>
Tue, 23 Jun 2009 14:51:59 +0000
(14:51 +0000)
python/vserver.py
patch
|
blob
|
history
diff --git
a/python/vserver.py
b/python/vserver.py
index
a4b063b
..
fa58beb
100644
(file)
--- a/
python/vserver.py
+++ b/
python/vserver.py
@@
-41,6
+41,8
@@
RLIMITS = { "NSOCK": VLIMIT_NSOCK,
"ANON": VLIMIT_ANON,
"SHMEM": VLIMIT_SHMEM}
"ANON": VLIMIT_ANON,
"SHMEM": VLIMIT_SHMEM}
+CPU_SHARE_MULT = 1024
+
# add in the platform supported rlimits
for entry in resource.__dict__.keys():
if entry.find("RLIMIT_")==0:
# add in the platform supported rlimits
for entry in resource.__dict__.keys():
if entry.find("RLIMIT_")==0:
@@
-332,24
+334,27
@@
class VServer:
def set_sched_config(self, cpu_min, cpu_share):
""" Write current CPU scheduler parameters to the vserver
def set_sched_config(self, cpu_min, cpu_share):
""" Write current CPU scheduler parameters to the vserver
- configuration file. This method does not modify the kernel CPU
- scheduling parameters for this context. """
-
- self.config.update('sched/fill-rate', cpu_min)
- self.config.update('sched/fill-rate2', cpu_share)
- if cpu_share == 0:
- self.config.unset('sched/idle-time')
-
+ configuration file. Currently, 'cpu_min' is not supported. """
+ self.config.update('cgroup/cpu.shares', cpu_share * CPU_SHARE_MULT)
if self.is_running():
self.set_sched(cpu_min, cpu_share)
def set_sched(self, cpu_min, cpu_share):
if self.is_running():
self.set_sched(cpu_min, cpu_share)
def set_sched(self, cpu_min, cpu_share):
- """ Update kernel CPU scheduling parameters for this context. """
- vserverimpl.setsched(self.ctx, cpu_min, cpu_share)
+ """ Update kernel CPU scheduling parameters for this context.
+ Currently, 'cpu_min' is not supported. """
+ try:
+ cgroup = open('/dev/cgroup/%s/cpu.shares' % name, 'w')
+ cgroup.write('%s' % (cpu_share * CPU_SHARE_MULT))
+ cgroup.close()
+ except:
+ pass
def get_sched(self):
def get_sched(self):
- # have no way of querying scheduler right now on a per vserver basis
- return (-1, False)
+ try:
+ cpu_share = int(int(self.config.get('cgroup/cpu.shares')) / CPU_SHARE_MULT)
+ except:
+ cpu_share = False
+ return (-1, cpu_share)
def set_bwlimit(self, minrate = bwlimit.bwmin, maxrate = None,
exempt_min = None, exempt_max = None,
def set_bwlimit(self, minrate = bwlimit.bwmin, maxrate = None,
exempt_min = None, exempt_max = None,