]> git.hungrycats.org Git - linux/commit
xsk: fix batch alloc API on non-coherent systems
authorMaciej Fijalkowski <maciej.fijalkowski@intel.com>
Wed, 11 Sep 2024 19:10:19 +0000 (21:10 +0200)
committerJakub Kicinski <kuba@kernel.org>
Sat, 14 Sep 2024 00:36:16 +0000 (17:36 -0700)
commit4144a1059b47e821c82c3c82eb23a4c7312dce3a
tree1f6445e65e7eb12bd950d3aeee300d68c8b051c6
parent1f2e900ac26fed3b1d11dbcb9f25589644330112
xsk: fix batch alloc API on non-coherent systems

In cases when synchronizing DMA operations is necessary,
xsk_buff_alloc_batch() returns a single buffer instead of the requested
count. This puts the pressure on drivers that use batch API as they have
to check for this corner case on their side and take care of allocations
by themselves, which feels counter productive. Let us improve the core
by looping over xp_alloc() @max times when slow path needs to be taken.

Another issue with current interface, as spotted and fixed by Dries, was
that when driver called xsk_buff_alloc_batch() with @max == 0, for slow
path case it still allocated and returned a single buffer, which should
not happen. By introducing the logic from first paragraph we kill two
birds with one stone and address this problem as well.

Fixes: 47e4075df300 ("xsk: Batched buffer allocation for the pool")
Reported-and-tested-by: Dries De Winter <ddewinter@synamedia.com>
Co-developed-by: Dries De Winter <ddewinter@synamedia.com>
Signed-off-by: Dries De Winter <ddewinter@synamedia.com>
Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Acked-by: Magnus Karlsson <magnus.karlsson@intel.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20240911191019.296480-1-maciej.fijalkowski@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/xdp/xsk_buff_pool.c