]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
af-packet: no more threads than RSS queues 1238/head
authorEric Leblond <eric@regit.org>
Thu, 4 Dec 2014 16:58:25 +0000 (17:58 +0100)
committerEric Leblond <eric@regit.org>
Thu, 4 Dec 2014 17:17:39 +0000 (18:17 +0100)
If we manage to read the number of RSS queues from an interface,
this means that the optimal number of capture threads is equal
to the minimum of this number and of the number of cores on the
system.

This patch implements this logic thanks to the newly introduced
function GetIfaceRSSQueuesNum.

src/runmode-af-packet.c

index 64b1985989500fae64e995d198020a173398953b..4c071f3529a796d7521214986aefab4b0aa42972 100644 (file)
@@ -52,6 +52,7 @@
 #include "util-affinity.h"
 #include "util-device.h"
 #include "util-runmodes.h"
+#include "util-ioctl.h"
 
 #include "source-af-packet.h"
 
@@ -184,7 +185,17 @@ void *ParseAFPConfig(const char *iface)
         }
     }
     if (aconf->threads == 0) {
+        int rss_queues;
         aconf->threads = (int)UtilCpuGetNumProcessorsOnline();
+        /* Get the number of RSS queues and take the min */
+        rss_queues = GetIfaceRSSQueuesNum(iface);
+        if (rss_queues > 0) {
+            if (rss_queues < aconf->threads) {
+                aconf->threads = rss_queues;
+                SCLogInfo("More core than RSS queues, using %d threads for interface %s",
+                          aconf->threads, iface);
+            }
+        }
         if (aconf->threads)
             SCLogInfo("Using %d AF_PACKET threads for interface %s", aconf->threads, iface);
     }