Revision 08d611f4 mininet/node.py
mininet/node.py | ||
---|---|---|
510 | 510 |
value may also be list or dict""" |
511 | 511 |
name, value = param.items()[ 0 ] |
512 | 512 |
f = getattr( self, method, None ) |
513 |
if not f or value is None:
|
|
513 |
if not f: |
|
514 | 514 |
return |
515 | 515 |
if type( value ) is list: |
516 | 516 |
result = f( *value ) |
... | ... | |
655 | 655 |
# Tell mnexec to execute command in our cgroup |
656 | 656 |
mncmd = [ 'mnexec', '-g', self.name, |
657 | 657 |
'-da', str( self.pid ) ] |
658 |
if self.sched == 'rt': |
|
658 |
cpuTime = int( self.cgroupGet( 'rt_runtime_us', 'cpu' ) ) |
|
659 |
# if our cgroup is not given any cpu time, |
|
660 |
# we cannot assign the RR Scheduler. |
|
661 |
if self.sched == 'rt' and cpuTime > 0: |
|
659 | 662 |
mncmd += [ '-r', str( self.rtprio ) ] |
663 |
elif self.sched == 'rt' and cpuTime <= 0: |
|
664 |
debug( '***error: not enough cpu time available for %s.' % self.name, |
|
665 |
'Using cfs scheduler for subprocess\n' ) |
|
660 | 666 |
return Host.popen( self, *args, mncmd=mncmd, **kwargs ) |
661 | 667 |
|
662 | 668 |
def cleanup( self ): |
... | ... | |
707 | 713 |
f: CPU bandwidth limit (fraction) |
708 | 714 |
sched: 'rt' or 'cfs' |
709 | 715 |
Note 'cfs' requires CONFIG_CFS_BANDWIDTH""" |
716 |
# if cpu fraction is None, reset to default of 0 |
|
710 | 717 |
if not f: |
711 |
return
|
|
718 |
f = -1
|
|
712 | 719 |
if not sched: |
713 | 720 |
sched = self.sched |
714 | 721 |
if sched == 'rt': |
... | ... | |
721 | 728 |
# Reset to unlimited |
722 | 729 |
quota = -1 |
723 | 730 |
# Set cgroup's period and quota |
724 |
self.cgroupSet( pstr, period ) |
|
725 |
self.cgroupSet( qstr, quota ) |
|
731 |
setPeriod = self.cgroupSet( pstr, period )
|
|
732 |
setQuota = self.cgroupSet( qstr, quota )
|
|
726 | 733 |
if sched == 'rt': |
727 | 734 |
# Set RT priority if necessary |
728 |
self.chrt() |
|
729 |
info( '(%s %d/%dus) ' % ( sched, quota, period ) )
|
|
735 |
sched = self.chrt()
|
|
736 |
info( '(%s %d/%dus) ' % ( sched, setQuota, setPeriod ) )
|
|
730 | 737 |
|
731 | 738 |
def setCPUs( self, cores, mems=0 ): |
732 | 739 |
"Specify (real) cores that our cgroup can run on" |
740 |
if not cores: |
|
741 |
return |
|
733 | 742 |
if type( cores ) is list: |
734 | 743 |
cores = ','.join( [ str( c ) for c in cores ] ) |
735 | 744 |
self.cgroupSet( resource='cpuset', param='cpus', |
... | ... | |
743 | 752 |
errFail( 'cgclassify -g cpuset:/%s %s' % ( |
744 | 753 |
self.name, self.pid ) ) |
745 | 754 |
|
746 |
def config( self, cpu=None, cores=None, **params ):
|
|
755 |
def config( self, cpu=-1, cores=None, **params ):
|
|
747 | 756 |
"""cpu: desired overall system CPU fraction |
748 | 757 |
cores: (real) core(s) this host can run on |
749 | 758 |
params: parameters for Node.config()""" |
Also available in: Unified diff