Skip to content

Commit

Permalink
Added: autoxps utility.
Browse files Browse the repository at this point in the history
  • Loading branch information
strizhechenko committed Jul 11, 2017
1 parent b59c080 commit 86bce0f
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 12 deletions.
14 changes: 7 additions & 7 deletions netutils_linux_tuning/autorps.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
class AutoRPS(CPUBasedTune):
""" Allows to use multi-cpu packets processing for budget NICs """
numa = None
target = 'rps_cpus'
queue_prefix = 'rx'

def __init__(self):
CPUBasedTune.__init__(self)
Expand All @@ -20,7 +22,7 @@ def __init__(self):

def parse(self):
""" :return: queue list to write cpu mask """
return ['rx-0'] if self.options.test_dir else self.detect_queues_real()
return ["{0}-0".format(self.queue_prefix)] if self.options.test_dir else self.detect_queues_real()

def eval(self):
""" Evaluates CPU mask used as decision for the apply() """
Expand All @@ -40,20 +42,18 @@ def apply(self, decision):
print_("Using mask '{0}' for {1}-{2}".format(self.options.cpu_mask, self.options.dev, queue))
if self.options.dry_run:
continue
with open(os.path.join(queue_dir, queue, 'rps_cpus'), 'w') as queue_file:
with open(os.path.join(queue_dir, queue, self.target), 'w') as queue_file:
queue_file.write(self.options.cpu_mask)

@staticmethod
def parse_options():
def parse_options(self):
"""
:return: options for AutoRPS
"""
parser = CPUBasedTune.make_parser()
parser.add_argument('-f', '--force', help="Work even in case of multiqueue CPU", action='store_true',
default=False)
parser.add_argument('-m', '--cpu-mask', help='Explicitly define mask to write in rps_cpus', type=str)

return parser.parse_args()
parser.add_argument('-m', '--cpu-mask', help='Explicitly define mask to write in {0}'.format(self.target),
type=str)

@staticmethod
def cpus2mask(cpus, cpus_count):
Expand Down
14 changes: 14 additions & 0 deletions netutils_linux_tuning/autoxps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# coding=utf-8
""" Transmit Packet Steering tuning utility """

from netutils_linux_tuning.autorps import AutoRPS


class AutoXPS(AutoRPS):
""" Allows to use multi-cpu packets processing for budget NICs """
numa = None
target = 'xps_cpus'
queue_prefix = 'tx'

def __init__(self):
AutoRPS.__init__(self)
3 changes: 1 addition & 2 deletions netutils_linux_tuning/base_tune.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ def make_parser():
parser.add_argument('-d', '--dry-run', help="Don't apply any settings.", action='store_true', default=False)
return parser

@staticmethod
@abstractmethod
def parse_options():
def parse_options(self):
""" Parse options for specific util """

@abstractmethod
Expand Down
3 changes: 1 addition & 2 deletions netutils_linux_tuning/rss_ladder.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ def cpu_colorize(self, cpu):
return cpu
return wrap(cpu, cpu_color(cpu, numa=self.numa))

@staticmethod
def parse_options():
def parse_options(self):
"""
:return: parsed arguments
"""
Expand Down
4 changes: 3 additions & 1 deletion tests/utils_runnable
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ link-rate --no-clear -n 1 --random --devices="$devices"
irqtop --no-clear -n 1 --random --interrupts-file="$irq"
softirq-top --no-clear -n 1 --random --softirqs-file="$softirq"
softnet-stat-top --no-clear -n 1 --random --softnet-stat-file="$soft_net_stat"

autorps --help
autoxps --help
rss-ladder --help
8 changes: 8 additions & 0 deletions utils/autoxps
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env python

# coding=utf-8

from netutils_linux_tuning.autoxps import AutoXPS

if __name__ == '__main__':
AutoXPS()

0 comments on commit 86bce0f

Please sign in to comment.