BBlack has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/188112

Change subject: Autodetect RSS patterns in interface-rps
......................................................................

Autodetect RSS patterns in interface-rps

Change-Id: I2c442cf0c8d6822cad83dd08607cd3c5f145ca63
---
M modules/interface/files/interface-rps.py
1 file changed, 23 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/12/188112/1

diff --git a/modules/interface/files/interface-rps.py 
b/modules/interface/files/interface-rps.py
index b1f95dc..135fdc3 100755
--- a/modules/interface/files/interface-rps.py
+++ b/modules/interface/files/interface-rps.py
@@ -6,9 +6,17 @@
 # what's common advice out there (all CPUs to all queues), as experience has
 # shown a tremendous difference.
 #
-# Optionally sets up matching Receive Side Scaling (RSS) IRQ affinities if
-# given a second parameter for lookups in /proc/interrupts.  e.g. for
-# bnx2x, this would be "eth0-fp-%d".
+# The first 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 RSS IRQ name parameter is not specified, the code will try to
+# auto-detect the pattern by searching /proc/interrupts for the 0th RSS
+# IRQ based on the supplied device name, e.g. /eth0[^\s0-9]*0$/.  If
+# detection fails, RSS will not be set up.
 #
 # Sets up matching Transmit Packet Steering (XPS) queues if possible as
 # well.  There are only two XPS cases currently covered: generic support
@@ -29,7 +37,7 @@
 # need to be addressed individually when we encounter them.
 #
 # Authors: Faidon Liambotis and Brandon Black
-# Copyright (c) 2013-2014 Wikimedia Foundation, Inc.
+# Copyright (c) 2013-2015 Wikimedia Foundation, Inc.
 
 import os
 import glob
@@ -94,6 +102,16 @@
         tx_qmap[rxq] = [rxq + (c * len(rx_queues)) for c in range(cos_bands)]
     return tx_qmap
 
+def detect_rss_pattern(device):
+    """Detect RSS IRQ Name pattern based on device, if possible"""
+
+    rss_patt_re = re.compile(r'^\s*[0-9]+:.*\s' + device + r'([^\s0-9]*)0\n$')
+    irq_file = open('/proc/interrupts', 'r')
+    for line in irq_file:
+        match = rss_patt_re.match(line)
+        if match:
+            return device + match.group(1) + '%d'
+    return None
 
 def get_rx_irqs(rss_pattern, rx_queues):
     """Find RSS IRQs for rx queues matching rss_pattern (e.g. 'eth0-fp-%d')"""
@@ -181,7 +199,7 @@
     try:
         rss_pattern = sys.argv[2]
     except IndexError:
-        rss_pattern = None
+        rss_pattern = detect_rss_pattern(device)
 
     cpu_list = get_cpu_list()
     rx_queues = get_queues(device, 'rx')

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2c442cf0c8d6822cad83dd08607cd3c5f145ca63
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: BBlack <[email protected]>

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

Reply via email to