BBlack has submitted this change and it was merged.

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, 28 insertions(+), 5 deletions(-)

Approvals:
  BBlack: Verified; Looks good to me, approved



diff --git a/modules/interface/files/interface-rps.py 
b/modules/interface/files/interface-rps.py
index b1f95dc..0f1fc24 100755
--- a/modules/interface/files/interface-rps.py
+++ b/modules/interface/files/interface-rps.py
@@ -2,13 +2,24 @@
 
 # Sets up scalable network stuff (RPS/RSS/XPS) for a given interface.
 #
+# For basic technical background:
+# https://www.kernel.org/doc/Documentation/networking/scaling.txt
+#
 # Tries to allocate separate queues to separate CPUs, rather than follow
 # 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 +40,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
@@ -93,6 +104,18 @@
     for rxq in rx_queues:
         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):
@@ -181,7 +204,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: merged
Gerrit-Change-Id: I2c442cf0c8d6822cad83dd08607cd3c5f145ca63
Gerrit-PatchSet: 6
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