Skip to content

Commit 07bbecb

Browse files
Alex BelitsPeter Zijlstra
authored andcommitted
net: Restrict receive packets queuing to housekeeping CPUs
With the existing implementation of store_rps_map(), packets are queued in the receive path on the backlog queues of other CPUs irrespective of whether they are isolated or not. This could add a latency overhead to any RT workload that is running on the same CPU. Ensure that store_rps_map() only uses available housekeeping CPUs for storing the rps_map. Signed-off-by: Alex Belits <abelits@marvell.com> Signed-off-by: Nitesh Narayan Lal <nitesh@redhat.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/20200625223443.2684-4-nitesh@redhat.com
1 parent 69a18b1 commit 07bbecb

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

net/core/net-sysfs.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/if_arp.h>
1212
#include <linux/slab.h>
1313
#include <linux/sched/signal.h>
14+
#include <linux/sched/isolation.h>
1415
#include <linux/nsproxy.h>
1516
#include <net/sock.h>
1617
#include <net/net_namespace.h>
@@ -741,7 +742,7 @@ static ssize_t store_rps_map(struct netdev_rx_queue *queue,
741742
{
742743
struct rps_map *old_map, *map;
743744
cpumask_var_t mask;
744-
int err, cpu, i;
745+
int err, cpu, i, hk_flags;
745746
static DEFINE_MUTEX(rps_map_mutex);
746747

747748
if (!capable(CAP_NET_ADMIN))
@@ -756,6 +757,13 @@ static ssize_t store_rps_map(struct netdev_rx_queue *queue,
756757
return err;
757758
}
758759

760+
hk_flags = HK_FLAG_DOMAIN | HK_FLAG_WQ;
761+
cpumask_and(mask, mask, housekeeping_cpumask(hk_flags));
762+
if (cpumask_empty(mask)) {
763+
free_cpumask_var(mask);
764+
return -EINVAL;
765+
}
766+
759767
map = kzalloc(max_t(unsigned int,
760768
RPS_MAP_SIZE(cpumask_weight(mask)), L1_CACHE_BYTES),
761769
GFP_KERNEL);

0 commit comments

Comments
 (0)