From 56373e5b347fb939ca0e2c9addb5cefd2947f979 Mon Sep 17 00:00:00 2001 From: Eric Leblond Date: Thu, 4 Dec 2014 17:58:25 +0100 Subject: [PATCH] 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. --- src/runmode-af-packet.c | 11 +++++++++++ 1 file changed, 11 insertions(+) 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); }