Unlimit cfs hosts for startup/shutdown config (#1178)
We defer cfs cgroup bandwidth limiting until CPULimitedHost.configDefault(), and we change Mininet.stop() to call a new host.unlimit() method if available.
This commit is contained in:
@@ -572,6 +572,10 @@ class Mininet( object ):
|
|||||||
info( controller.name + ' ' )
|
info( controller.name + ' ' )
|
||||||
controller.stop()
|
controller.stop()
|
||||||
info( '\n' )
|
info( '\n' )
|
||||||
|
# Unlimit cfs hosts to speed up shutdown
|
||||||
|
for h in self.hosts:
|
||||||
|
if hasattr( h, 'unlimit' ):
|
||||||
|
h.unlimit()
|
||||||
if self.terms:
|
if self.terms:
|
||||||
info( '*** Stopping %i terms\n' % len( self.terms ) )
|
info( '*** Stopping %i terms\n' % len( self.terms ) )
|
||||||
self.stopXterms()
|
self.stopXterms()
|
||||||
|
|||||||
+22
-9
@@ -685,8 +685,21 @@ class CPULimitedHost( Host ):
|
|||||||
|
|
||||||
"CPU limited host"
|
"CPU limited host"
|
||||||
|
|
||||||
def __init__( self, name, sched='cfs', **kwargs ):
|
def __init__( self, name, sched='cfs', **params ):
|
||||||
Host.__init__( self, name, **kwargs )
|
Host.__init__( self, name, **params )
|
||||||
|
# BL: Setting the correct period/quota is tricky, particularly
|
||||||
|
# for RT. RT allows very small quotas, but the overhead
|
||||||
|
# seems to be high. CFS has a mininimum quota of 1 ms, but
|
||||||
|
# still does better with larger period values.
|
||||||
|
self.period_us = params.get( 'period_us', 100000 )
|
||||||
|
self.sched = sched
|
||||||
|
self.cgroupsInited = False
|
||||||
|
self.cgroup, self.rtprio = None, None
|
||||||
|
|
||||||
|
def initCgroups( self ):
|
||||||
|
"Deferred cgroup initialization"
|
||||||
|
if self.cgroupsInited:
|
||||||
|
return
|
||||||
# Initialize class if necessary
|
# Initialize class if necessary
|
||||||
if not CPULimitedHost.inited:
|
if not CPULimitedHost.inited:
|
||||||
CPULimitedHost.init()
|
CPULimitedHost.init()
|
||||||
@@ -696,13 +709,7 @@ class CPULimitedHost( Host ):
|
|||||||
# We don't add ourselves to a cpuset because you must
|
# We don't add ourselves to a cpuset because you must
|
||||||
# specify the cpu and memory placement first
|
# specify the cpu and memory placement first
|
||||||
errFail( 'cgclassify -g cpu,cpuacct:/%s %s' % ( self.name, self.pid ) )
|
errFail( 'cgclassify -g cpu,cpuacct:/%s %s' % ( self.name, self.pid ) )
|
||||||
# BL: Setting the correct period/quota is tricky, particularly
|
if self.sched == 'rt':
|
||||||
# for RT. RT allows very small quotas, but the overhead
|
|
||||||
# seems to be high. CFS has a mininimum quota of 1 ms, but
|
|
||||||
# still does better with larger period values.
|
|
||||||
self.period_us = kwargs.get( 'period_us', 100000 )
|
|
||||||
self.sched = sched
|
|
||||||
if sched == 'rt':
|
|
||||||
self.checkRtGroupSched()
|
self.checkRtGroupSched()
|
||||||
self.rtprio = 20
|
self.rtprio = 20
|
||||||
|
|
||||||
@@ -863,6 +870,7 @@ class CPULimitedHost( Host ):
|
|||||||
cores: (real) core(s) this host can run on
|
cores: (real) core(s) this host can run on
|
||||||
params: parameters for Node.config()"""
|
params: parameters for Node.config()"""
|
||||||
r = Node.config( self, **params )
|
r = Node.config( self, **params )
|
||||||
|
self.initCgroups()
|
||||||
# Was considering cpu={'cpu': cpu , 'sched': sched}, but
|
# Was considering cpu={'cpu': cpu , 'sched': sched}, but
|
||||||
# that seems redundant
|
# that seems redundant
|
||||||
self.setParam( r, 'setCPUFrac', cpu=cpu )
|
self.setParam( r, 'setCPUFrac', cpu=cpu )
|
||||||
@@ -878,6 +886,11 @@ class CPULimitedHost( Host ):
|
|||||||
cls.cgversion = mountCgroups()
|
cls.cgversion = mountCgroups()
|
||||||
cls.inited = True
|
cls.inited = True
|
||||||
|
|
||||||
|
def unlimit( self ):
|
||||||
|
"Unlimit cpu for cfs"
|
||||||
|
if self.sched == 'cfs' and self.params.get( 'cpu', -1 ) != -1:
|
||||||
|
self.setCPUFrac( -1, sched=self.sched )
|
||||||
|
|
||||||
|
|
||||||
# Some important things to note:
|
# Some important things to note:
|
||||||
#
|
#
|
||||||
|
|||||||
Reference in New Issue
Block a user