From 4ec357da0a27ef3931b51f9d5d0bffd9ebe92e74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Wed, 3 Jun 2020 11:01:19 +0200 Subject: [PATCH] Don't check the result of setting SO_INCOMING_CPU The SO_INCOMING_CPU is available since Linux 3.19 for getting the value, but only since Linux 4.4 for setting the value (see below for a full description). BIND 9 should not fail when setting the option on the socket fails, as this is only an optimization and not hard requirement to run BIND 9. SO_INCOMING_CPU (gettable since Linux 3.19, settable since Linux 4.4) Sets or gets the CPU affinity of a socket. Expects an integer flag. int cpu = 1; setsockopt(fd, SOL_SOCKET, SO_INCOMING_CPU, &cpu, sizeof(cpu)); Because all of the packets for a single stream (i.e., all packets for the same 4-tuple) arrive on the single RX queue that is associated with a particular CPU, the typical use case is to employ one listening process per RX queue, with the incoming flow being handled by a listener on the same CPU that is handling the RX queue. This provides optimal NUMA behavior and keeps CPU caches hot. --- lib/isc/netmgr/udp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/isc/netmgr/udp.c b/lib/isc/netmgr/udp.c index 1b642b8928..066e5edcb5 100644 --- a/lib/isc/netmgr/udp.c +++ b/lib/isc/netmgr/udp.c @@ -115,9 +115,12 @@ isc_nm_listenudp(isc_nm_t *mgr, isc_nmiface_t *iface, isc_nm_recv_cb_t cb, #endif #ifdef SO_INCOMING_CPU - res = setsockopt(csock->fd, SOL_SOCKET, SO_INCOMING_CPU, + /* We don't check for the result, because SO_INCOMING_CPU can be + * available without the setter on Linux kernel version 4.4, and + * setting SO_INCOMING_CPU is just an optimization. + */ + (void)setsockopt(csock->fd, SOL_SOCKET, SO_INCOMING_CPU, &(int){ 1 }, sizeof(int)); - RUNTIME_CHECK(res == 0); #endif ievent = isc__nm_get_ievent(mgr, netievent_udplisten); ievent->sock = csock;