Merge pull request #374 from cdburkard/patches/rt

check if RT_GROUP_SCHED is enabled in kernel
This commit is contained in:
Brian O'Connor
2014-09-20 23:21:06 -07:00
2 changed files with 17 additions and 6 deletions
+11 -6
View File
@@ -8,15 +8,14 @@ from mininet.net import Mininet
from mininet.link import TCIntf from mininet.link import TCIntf
from mininet.node import CPULimitedHost from mininet.node import CPULimitedHost
from mininet.topolib import TreeTopo from mininet.topolib import TreeTopo
from mininet.util import custom from mininet.util import custom, quietRun
from mininet.log import setLogLevel from mininet.log import setLogLevel, info
def testLinkLimit( net, bw ): def testLinkLimit( net, bw ):
"Run bandwidth limit test" "Run bandwidth limit test"
print '*** Testing network %.2f Mbps bandwidth limit' % bw info( '*** Testing network %.2f Mbps bandwidth limit\n' % bw )
net.iperf( ) net.iperf()
def limit( bw=10, cpu=.1 ): def limit( bw=10, cpu=.1 ):
"""Example/test of link and CPU bandwidth limits """Example/test of link and CPU bandwidth limits
@@ -25,7 +24,13 @@ def limit( bw=10, cpu=.1 ):
intf = custom( TCIntf, bw=bw ) intf = custom( TCIntf, bw=bw )
myTopo = TreeTopo( depth=1, fanout=2 ) myTopo = TreeTopo( depth=1, fanout=2 )
for sched in 'rt', 'cfs': for sched in 'rt', 'cfs':
print '*** Testing with', sched, 'bandwidth limiting' info( '*** Testing with', sched, 'bandwidth limiting\n' )
if sched == 'rt':
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':
info( '*** RT Scheduler is not enabled in your kernel. Skipping this test\n' )
continue
host = custom( CPULimitedHost, sched=sched, cpu=cpu ) host = custom( CPULimitedHost, sched=sched, cpu=cpu )
net = Mininet( topo=myTopo, intf=intf, host=host ) net = Mininet( topo=myTopo, intf=intf, host=host )
net.start() net.start()
+6
View File
@@ -617,6 +617,12 @@ class CPULimitedHost( Host ):
# still does better with larger period values. # still does better with larger period values.
self.period_us = kwargs.get( 'period_us', 100000 ) self.period_us = kwargs.get( 'period_us', 100000 )
self.sched = sched self.sched = sched
if self.sched == 'rt':
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 )
self.rtprio = 20 self.rtprio = 20
def cgroupSet( self, param, value, resource='cpu' ): def cgroupSet( self, param, value, resource='cpu' ):