BBlack has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/355218 )

Change subject: RPS cleanup 4/5: Add config file to script, use for rss_pattern
......................................................................


RPS cleanup 4/5: Add config file to script, use for rss_pattern

Change-Id: I6b4e996d994810d859d2c7d09795907d80f3945c
---
M modules/interface/files/interface-rps.py
1 file changed, 31 insertions(+), 9 deletions(-)

Approvals:
  BBlack: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/interface/files/interface-rps.py 
b/modules/interface/files/interface-rps.py
index 5fbc6f1..eded02c 100755
--- a/modules/interface/files/interface-rps.py
+++ b/modules/interface/files/interface-rps.py
@@ -9,12 +9,17 @@
 # what's common advice out there (all CPUs to all queues), as experience has
 # shown a tremendous difference.
 #
-# The first param is the ethernet interfaces (e.g. 'eth0') and is required.
+# The only param is the ethernet interfaces (e.g. 'eth0') and is required.
 #
-# The second param is an optional RSS (Receive Side Scaling) IRQ name
-# pattern for finding device IRQs in /proc/interrupts.  It must contain a
-# single '%d' to match the queue number in the IRQ name.  For example, for
-# bnx2x this is 'eth0-fp-%d', and for bnx2 and tg3 it is 'eth0-%d'.
+# If the file /etc/interface-rps.d/$device exists, it will be parsed with
+# ConfigParser for an Options section to specify additional parameters for
+# this interface.
+#
+# The only currently-supported parameter is 'rss_pattern'.  This specifies an
+# optional RSS (Receive Side Scaling) IRQ name pattern for finding device IRQs
+# in /proc/interrupts.  It must contain a single '%d' to match the queue
+# number in the IRQ name.  For example, for bnx2x this is 'eth0-fp-%d', and
+# for bnx2 and tg3 it is 'eth0-%d'.
 #
 # If the RSS IRQ name parameter is not specified, the code will try to
 # auto-detect the pattern by searching /proc/interrupts for the 0th RSS
@@ -40,13 +45,14 @@
 # need to be addressed individually when we encounter them.
 #
 # Authors: Faidon Liambotis and Brandon Black
-# Copyright (c) 2013-2015 Wikimedia Foundation, Inc.
+# Copyright (c) 2013-2017 Wikimedia Foundation, Inc.
 
 import os
 import glob
 import sys
 import re
 import warnings
+import ConfigParser
 
 
 def get_value(path):
@@ -194,6 +200,20 @@
             set_cpus(device, cpus, rxq, rx_irqs[rxq], tx_qmap[rxq])
 
 
+def get_options(device):
+    """Get configured options from /etc/interface-rps.d/$device"""
+
+    config_file = os.path.join('/etc/interface-rps.d/', device)
+    if os.path.isfile(config_file):
+        config = ConfigParser.SafeConfigParser()
+        config.read([config_file])
+        opts = dict(config.items('Options'))
+    else:
+        opts = {}
+
+    return opts
+
+
 def main():
     """Simple main() function with sensible defaults"""
     try:
@@ -201,9 +221,11 @@
     except IndexError:
         device = 'eth0'
 
-    try:
-        rss_pattern = sys.argv[2]
-    except IndexError:
+    opts = get_options(device)
+
+    if 'rss_pattern' in opts:
+        rss_pattern = opts['rss_pattern']
+    else:
         rss_pattern = detect_rss_pattern(device)
 
     cpu_list = get_cpu_list()

-- 
To view, visit https://gerrit.wikimedia.org/r/355218
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I6b4e996d994810d859d2c7d09795907d80f3945c
Gerrit-PatchSet: 3
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: BBlack <[email protected]>
Gerrit-Reviewer: BBlack <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to