From: Witold Kręcicki Date: Wed, 29 Jan 2020 08:29:19 +0000 (+0100) Subject: Use the original threadid when sending a UDP packet to decrease probability of contex... X-Git-Tag: v9.17.1~90^2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb874608c1929df6b2fa81ec31b64b3901e85c16;p=thirdparty%2Fbind9.git Use the original threadid when sending a UDP packet to decrease probability of context switching --- diff --git a/lib/isc/netmgr/udp.c b/lib/isc/netmgr/udp.c index 6e229e1eea6..84ac0d65278 100644 --- a/lib/isc/netmgr/udp.c +++ b/lib/isc/netmgr/udp.c @@ -383,8 +383,16 @@ isc__nm_udp_send(isc_nmhandle_t *handle, isc_region_t *region, isc_nm_cb_t cb, return (ISC_R_CANCELED); } + /* + * If we're in netthread - send it directly + * If the original packet was received over a regular socket + * - send it over the same thread (assuming cpu affinity) + * Otherwise - use a random thread. + */ if (isc__nm_in_netthread()) { ntid = isc_nm_tid(); + } else if (sock->type == isc_nm_udpsocket) { + ntid = sock->tid; } else { ntid = (int)isc_random_uniform(sock->nchildren); }