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.
#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;