Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

xsk: Bump xsk_queue::queue_empty_descs in xp_can_alloc()

We have STAT_FILL_EMPTY test case in xskxceiver that tries to process
traffic with fill queue being empty which currently fails for zero copy
ice driver after it started to use xsk_buff_can_alloc() API. That is
because xsk_queue::queue_empty_descs is currently only increased from
alloc APIs and right now if driver sees that xsk_buff_pool will be
unable to provide the requested count of buffers, it bails out early,
skipping calls to xsk_buff_alloc{_batch}().

Mentioned statistic should be handled in xsk_buff_can_alloc() from the
very beginning, so let's add this logic now. Do it by open coding
xskq_cons_has_entries() and bumping queue_empty_descs in the middle when
fill queue currently has no entries.

Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Magnus Karlsson <magnus.karlsson@intel.com>
Link: https://lore.kernel.org/bpf/20240904162808.249160-1-maciej.fijalkowski@intel.com

authored by

Maciej Fijalkowski and committed by
Daniel Borkmann
6b083650 5d162283

+9 -6
+9 -1
net/xdp/xsk_buff_pool.c
··· 656 656 657 657 bool xp_can_alloc(struct xsk_buff_pool *pool, u32 count) 658 658 { 659 + u32 req_count, avail_count; 660 + 659 661 if (pool->free_list_cnt >= count) 660 662 return true; 661 - return xskq_cons_has_entries(pool->fq, count - pool->free_list_cnt); 663 + 664 + req_count = count - pool->free_list_cnt; 665 + avail_count = xskq_cons_nb_entries(pool->fq, req_count); 666 + if (!avail_count) 667 + pool->fq->queue_empty_descs++; 668 + 669 + return avail_count >= req_count; 662 670 } 663 671 EXPORT_SYMBOL(xp_can_alloc); 664 672
-5
net/xdp/xsk_queue.h
··· 306 306 return entries >= max ? max : entries; 307 307 } 308 308 309 - static inline bool xskq_cons_has_entries(struct xsk_queue *q, u32 cnt) 310 - { 311 - return xskq_cons_nb_entries(q, cnt) >= cnt; 312 - } 313 - 314 309 static inline bool xskq_cons_peek_addr_unchecked(struct xsk_queue *q, u64 *addr) 315 310 { 316 311 if (q->cached_prod == q->cached_cons)