xsk: Bring back busy polling support
authorStanislav Fomichev <sdf@fomichev.me>
Thu, 9 Jan 2025 00:34:36 +0000 (16:34 -0800)
committerJakub Kicinski <kuba@kernel.org>
Sat, 11 Jan 2025 02:07:56 +0000 (18:07 -0800)
commit5ef44b3cb43bda4009ba7fe3d54e0d258ae4aee7
tree89dd1c25f659def19c1d49b77f49416138434e02
parentf0aa6a37a3dbb40b272df5fc6db93c114688adcd
xsk: Bring back busy polling support

Commit 86e25f40aa1e ("net: napi: Add napi_config") moved napi->napi_id
assignment to a later point in time (napi_hash_add_with_id). This breaks
__xdp_rxq_info_reg which copies napi_id at an earlier time and now
stores 0 napi_id. It also makes sk_mark_napi_id_once_xdp and
__sk_mark_napi_id_once useless because they now work against 0 napi_id.
Since sk_busy_loop requires valid napi_id to busy-poll on, there is no way
to busy-poll AF_XDP sockets anymore.

Bring back the ability to busy-poll on XSK by resolving socket's napi_id
at bind time. This relies on relatively recent netif_queue_set_napi,
but (assume) at this point most popular drivers should have been converted.
This also removes per-tx/rx cycles which used to check and/or set
the napi_id value.

Confirmed by running a busy-polling AF_XDP socket
(github.com/fomichev/xskrtt) on mlx5 and looking at BusyPollRxPackets
from /proc/net/netstat.

Fixes: 86e25f40aa1e ("net: napi: Add napi_config")
Signed-off-by: Stanislav Fomichev <sdf@fomichev.me>
Acked-by: Magnus Karlsson <magnus.karlsson@intel.com>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Link: https://patch.msgid.link/20250109003436.2829560-1-sdf@fomichev.me
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/net/busy_poll.h
include/net/xdp.h
include/net/xdp_sock_drv.h
net/core/xdp.c
net/xdp/xsk.c