MCPcopy Create free account
hub / github.com/mininet/mininet / setCPUFrac

Method setCPUFrac

mininet/node.py:821–848  ·  view source on GitHub ↗

Set overall CPU fraction for this host f: CPU bandwidth limit (positive fraction, or -1 for cfs unlimited) sched: 'rt' or 'cfs' Note 'cfs' requires CONFIG_CFS_BANDWIDTH, and 'rt' requires CONFIG_RT_GROUP_SCHED

( self, f, sched=None )

Source from the content-addressed store, hash-verified

819 # all CPUs are the same.
820
821 def setCPUFrac( self, f, sched=None ):
822 """Set overall CPU fraction for this host
823 f: CPU bandwidth limit (positive fraction, or -1 for cfs unlimited)
824 sched: 'rt' or 'cfs'
825 Note 'cfs' requires CONFIG_CFS_BANDWIDTH,
826 and 'rt' requires CONFIG_RT_GROUP_SCHED"""
827 if not sched:
828 sched = self.sched
829 if sched == 'rt':
830 if not f or f < 0:
831 raise Exception( 'Please set a positive CPU fraction'
832 ' for sched=rt\n' )
833 pstr, qstr, period, quota = self.rtInfo( f )
834 elif sched == 'cfs':
835 pstr, qstr, period, quota = self.cfsInfo( f )
836 else:
837 return
838 # Set cgroup's period and quota
839 if self.cgversion == 'cgroup':
840 setPeriod = self.cgroupSet( pstr, period )
841 setQuota = self.cgroupSet( qstr, quota )
842 else:
843 setQuota, setPeriod = self.cgroupSet(
844 pstr, '%s %s' % (quota, period) ).split()
845 if sched == 'rt':
846 # Set RT priority if necessary
847 sched = self.chrt()
848 info( '(%s %s/%dus) ' % ( sched, setQuota, int( setPeriod ) ) )
849
850 def setCPUs( self, cores, mems=0 ):
851 "Specify (real) cores that our cgroup can run on"

Callers 2

unlimitMethod · 0.95
buildNodesMethod · 0.80

Calls 4

rtInfoMethod · 0.95
cfsInfoMethod · 0.95
cgroupSetMethod · 0.95
chrtMethod · 0.95

Tested by

no test coverage detected