From: Eric Leblond Date: Thu, 4 Dec 2014 16:58:25 +0000 (+0100) Subject: af-packet: no more threads than RSS queues X-Git-Tag: suricata-2.1beta3~117 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1238%2Fhead;p=thirdparty%2Fsuricata.git af-packet: no more threads than RSS queues 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. --- diff --git a/src/runmode-af-packet.c b/src/runmode-af-packet.c index 64b1985989..4c071f3529 100644 --- a/src/runmode-af-packet.c +++ b/src/runmode-af-packet.c @@ -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); }