Reorganize CFS and RT default/error conditions.
This commit is contained in:
+23
-22
@@ -689,6 +689,19 @@ class CPULimitedHost( Host ):
|
|||||||
super( CPULimitedHost, self ).cleanup()
|
super( CPULimitedHost, self ).cleanup()
|
||||||
retry( retries=3, delaySecs=1, fn=self.cgroupDel )
|
retry( retries=3, delaySecs=1, fn=self.cgroupDel )
|
||||||
|
|
||||||
|
_rtGroupSched = False # internal class var: Is CONFIG_RT_GROUP_SCHED set?
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def checkRtGroupSched( cls ):
|
||||||
|
"Check (Ubuntu,Debian) kernel config for CONFIG_RT_GROUP_SCHED for RT"
|
||||||
|
if not cls._rtGroupSched:
|
||||||
|
release = quietRun( 'uname -r' ).strip('\r\n')
|
||||||
|
output = quietRun( 'grep CONFIG_RT_GROUP_SCHED /boot/config-%s' % release )
|
||||||
|
if output == '# CONFIG_RT_GROUP_SCHED is not set\n':
|
||||||
|
error( '\n*** error: please enable RT_GROUP_SCHED in your kernel\n' )
|
||||||
|
exit( 1 )
|
||||||
|
cls._rtGroupSched = True
|
||||||
|
|
||||||
def chrt( self ):
|
def chrt( self ):
|
||||||
"Set RT scheduling priority"
|
"Set RT scheduling priority"
|
||||||
quietRun( 'chrt -p %s %s' % ( self.rtprio, self.pid ) )
|
quietRun( 'chrt -p %s %s' % ( self.rtprio, self.pid ) )
|
||||||
@@ -706,19 +719,6 @@ class CPULimitedHost( Host ):
|
|||||||
quota = int( self.period_us * f )
|
quota = int( self.period_us * f )
|
||||||
return pstr, qstr, self.period_us, quota
|
return pstr, qstr, self.period_us, quota
|
||||||
|
|
||||||
_rtGroupSched = False # internal class var: Is CONFIG_RT_GROUP_SCHED set?
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def checkRtGroupSched( cls ):
|
|
||||||
"Check (Ubuntu,Debian) kernel config for CONFIG_RT_GROUP_SCHED for RT"
|
|
||||||
if not cls._rtGroupSched:
|
|
||||||
release = quietRun( 'uname -r' ).strip('\r\n')
|
|
||||||
output = quietRun( 'grep CONFIG_RT_GROUP_SCHED /boot/config-%s' % release )
|
|
||||||
if output == '# CONFIG_RT_GROUP_SCHED is not set\n':
|
|
||||||
error( '\n*** error: please enable RT_GROUP_SCHED in your kernel\n' )
|
|
||||||
exit( 1 )
|
|
||||||
cls._rtGroupSched = True
|
|
||||||
|
|
||||||
def cfsInfo( self, f ):
|
def cfsInfo( self, f ):
|
||||||
"Internal method: return parameters for CFS bandwidth"
|
"Internal method: return parameters for CFS bandwidth"
|
||||||
pstr, qstr = 'cfs_period_us', 'cfs_quota_us'
|
pstr, qstr = 'cfs_period_us', 'cfs_quota_us'
|
||||||
@@ -729,6 +729,9 @@ class CPULimitedHost( Host ):
|
|||||||
debug( '(cfsInfo: increasing default period) ' )
|
debug( '(cfsInfo: increasing default period) ' )
|
||||||
quota = 1000
|
quota = 1000
|
||||||
period = int( quota / f / numCores() )
|
period = int( quota / f / numCores() )
|
||||||
|
# Reset to unlimited on negative quota
|
||||||
|
if quota < 0:
|
||||||
|
quota = -1
|
||||||
return pstr, qstr, period, quota
|
return pstr, qstr, period, quota
|
||||||
|
|
||||||
# BL comment:
|
# BL comment:
|
||||||
@@ -740,25 +743,23 @@ class CPULimitedHost( Host ):
|
|||||||
# to CPU seconds per second, essentially assuming that
|
# to CPU seconds per second, essentially assuming that
|
||||||
# all CPUs are the same.
|
# all CPUs are the same.
|
||||||
|
|
||||||
def setCPUFrac( self, f=-1, sched=None):
|
def setCPUFrac( self, f, sched=None ):
|
||||||
"""Set overall CPU fraction for this host
|
"""Set overall CPU fraction for this host
|
||||||
f: CPU bandwidth limit (fraction)
|
f: CPU bandwidth limit (positive fraction, or -1 for cfs unlimited)
|
||||||
sched: 'rt' or 'cfs'
|
sched: 'rt' or 'cfs'
|
||||||
Note 'cfs' requires CONFIG_CFS_BANDWIDTH"""
|
Note 'cfs' requires CONFIG_CFS_BANDWIDTH,
|
||||||
# if cpu fraction is None, reset to default of 0
|
and 'rt' requires CONFIG_RT_GROUP_SCHED"""
|
||||||
if not f:
|
|
||||||
f = -1
|
|
||||||
if not sched:
|
if not sched:
|
||||||
sched = self.sched
|
sched = self.sched
|
||||||
if sched == 'rt':
|
if sched == 'rt':
|
||||||
|
if not f or f < 0:
|
||||||
|
raise Exception( 'Please set a positive CPU fraction for sched=rt\n' )
|
||||||
|
return
|
||||||
pstr, qstr, period, quota = self.rtInfo( f )
|
pstr, qstr, period, quota = self.rtInfo( f )
|
||||||
elif sched == 'cfs':
|
elif sched == 'cfs':
|
||||||
pstr, qstr, period, quota = self.cfsInfo( f )
|
pstr, qstr, period, quota = self.cfsInfo( f )
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
if quota < 0:
|
|
||||||
# Reset to unlimited
|
|
||||||
quota = -1
|
|
||||||
# Set cgroup's period and quota
|
# Set cgroup's period and quota
|
||||||
setPeriod = self.cgroupSet( pstr, period )
|
setPeriod = self.cgroupSet( pstr, period )
|
||||||
setQuota = self.cgroupSet( qstr, quota )
|
setQuota = self.cgroupSet( qstr, quota )
|
||||||
|
|||||||
Reference in New Issue
Block a user