]> git.ipfire.org Git - thirdparty/linux.git/commit
xsk: avoid double checking against rx queue being full
authorMaciej Fijalkowski <maciej.fijalkowski@intel.com>
Wed, 18 Feb 2026 15:00:00 +0000 (16:00 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 25 Feb 2026 01:11:58 +0000 (17:11 -0800)
commitf620af11c27b8ec9994a39fe968aa778112d1566
tree70c515d18afdb27745989296243707470d7e9b7c
parent8ebfe65e22d5016c0ef2f7b5831117202493f794
xsk: avoid double checking against rx queue being full

Currently non-zc xsk rx path for multi-buffer case checks twice if xsk
rx queue has enough space for producing descriptors:
1.
if (xskq_prod_nb_free(xs->rx, num_desc) < num_desc) {
xs->rx_queue_full++;
return -ENOBUFS;
}
2.
__xsk_rcv_zc(xs, xskb, copied - meta_len, rem ? XDP_PKT_CONTD : 0);
-> err = xskq_prod_reserve_desc(xs->rx, addr, len, flags);
  -> if (xskq_prod_is_full(q))

Second part is redundant as in 1. we already peeked onto rx queue and
checked that there is enough space to produce given amount of
descriptors.

Provide helper functions that will skip it and therefore optimize code.

Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Reviewed-by: Jason Xing <kerneljasonxing@gmail.com>
Link: https://lore.kernel.org/r/20260218150000.301176-1-maciej.fijalkowski@intel.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
net/xdp/xsk.c
net/xdp/xsk_queue.h