All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf] xsk: mark napi_id on sendmsg()
@ 2022-06-29 10:57 Maciej Fijalkowski
  2022-06-29 12:45 ` Björn Töpel
  0 siblings, 1 reply; 10+ messages in thread
From: Maciej Fijalkowski @ 2022-06-29 10:57 UTC (permalink / raw)
  To: bpf, ast, daniel, andrii
  Cc: netdev, magnus.karlsson, bjorn, Maciej Fijalkowski

When application runs in zero copy busy poll mode and does not receive a
single packet but only sends them, it is currently impossible to get
into napi_busy_loop() as napi_id is only marked on Rx side in
xsk_rcv_check(). In there, napi_id is being taken from xdp_rxq_info
carried by xdp_buff. From Tx perspective, we do not have access to it.
What we have handy is the xsk pool.

Xsk pool works on a pool of internal xdp_buff wrappers called
xdp_buff_xsk. AF_XDP ZC enabled drivers call xp_set_rxq_info() so each
of xdp_buff_xsk has a valid pointer to xdp_rxq_info of underlying queue.
Therefore, on Tx side, napi_id can be pulled from
xs->pool->heads[0].xdp.rxq->napi_id.

Do this only for sockets working in ZC mode as otherwise rxq pointers
would not be initialized.

Fixes: a0731952d9cd ("xsk: Add busy-poll support for {recv,send}msg()")
Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
---
 net/xdp/xsk.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index 19ac872a6624..eafd512d38b1 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -637,8 +637,11 @@ static int __xsk_sendmsg(struct socket *sock, struct msghdr *m, size_t total_len
 	if (unlikely(need_wait))
 		return -EOPNOTSUPP;
 
-	if (sk_can_busy_loop(sk))
+	if (sk_can_busy_loop(sk)) {
+		if (xs->zc)
+			__sk_mark_napi_id_once(sk, xs->pool->heads[0].xdp.rxq->napi_id);
 		sk_busy_loop(sk, 1); /* only support non-blocking sockets */
+	}
 
 	if (xs->zc && xsk_no_wakeup(sk))
 		return 0;
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-06-30 15:52 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-29 10:57 [PATCH bpf] xsk: mark napi_id on sendmsg() Maciej Fijalkowski
2022-06-29 12:45 ` Björn Töpel
2022-06-29 12:53   ` Maciej Fijalkowski
2022-06-29 13:18     ` Magnus Karlsson
2022-06-29 16:16     ` Jakub Kicinski
2022-06-29 16:17       ` Jakub Kicinski
2022-06-30 11:53         ` Maciej Fijalkowski
2022-06-30 15:52           ` Jakub Kicinski
2022-06-29 13:39   ` Björn Töpel
2022-06-29 14:28     ` Maciej Fijalkowski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.