Skip to content

Commit 5ef44b3

Browse files
Stanislav Fomichevkuba-moo
authored andcommitted
xsk: Bring back busy polling support
Commit 86e25f4 ("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: 86e25f4 ("net: napi: Add napi_config") Signed-off-by: Stanislav Fomichev <[email protected]> Acked-by: Magnus Karlsson <[email protected]> Reviewed-by: Jakub Kicinski <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent f0aa6a3 commit 5ef44b3

File tree

5 files changed

+9
-29
lines changed

5 files changed

+9
-29
lines changed

include/net/busy_poll.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,4 @@ static inline void sk_mark_napi_id_once(struct sock *sk,
174174
#endif
175175
}
176176

177-
static inline void sk_mark_napi_id_once_xdp(struct sock *sk,
178-
const struct xdp_buff *xdp)
179-
{
180-
#ifdef CONFIG_NET_RX_BUSY_POLL
181-
__sk_mark_napi_id_once(sk, xdp->rxq->napi_id);
182-
#endif
183-
}
184-
185177
#endif /* _LINUX_NET_BUSY_POLL_H */

include/net/xdp.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ struct xdp_rxq_info {
6262
u32 queue_index;
6363
u32 reg_state;
6464
struct xdp_mem_info mem;
65-
unsigned int napi_id;
6665
u32 frag_size;
6766
} ____cacheline_aligned; /* perf critical, avoid false-sharing */
6867

include/net/xdp_sock_drv.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,6 @@ static inline void xsk_pool_fill_cb(struct xsk_buff_pool *pool,
5959
xp_fill_cb(pool, desc);
6060
}
6161

62-
static inline unsigned int xsk_pool_get_napi_id(struct xsk_buff_pool *pool)
63-
{
64-
#ifdef CONFIG_NET_RX_BUSY_POLL
65-
return pool->heads[0].xdp.rxq->napi_id;
66-
#else
67-
return 0;
68-
#endif
69-
}
70-
7162
static inline void xsk_pool_dma_unmap(struct xsk_buff_pool *pool,
7263
unsigned long attrs)
7364
{
@@ -306,11 +297,6 @@ static inline void xsk_pool_fill_cb(struct xsk_buff_pool *pool,
306297
{
307298
}
308299

309-
static inline unsigned int xsk_pool_get_napi_id(struct xsk_buff_pool *pool)
310-
{
311-
return 0;
312-
}
313-
314300
static inline void xsk_pool_dma_unmap(struct xsk_buff_pool *pool,
315301
unsigned long attrs)
316302
{

net/core/xdp.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ int __xdp_rxq_info_reg(struct xdp_rxq_info *xdp_rxq,
186186
xdp_rxq_info_init(xdp_rxq);
187187
xdp_rxq->dev = dev;
188188
xdp_rxq->queue_index = queue_index;
189-
xdp_rxq->napi_id = napi_id;
190189
xdp_rxq->frag_size = frag_size;
191190

192191
xdp_rxq->reg_state = REG_STATE_REGISTERED;

net/xdp/xsk.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ static int xsk_rcv_check(struct xdp_sock *xs, struct xdp_buff *xdp, u32 len)
322322
return -ENOSPC;
323323
}
324324

325-
sk_mark_napi_id_once_xdp(&xs->sk, xdp);
326325
return 0;
327326
}
328327

@@ -908,11 +907,8 @@ static int __xsk_sendmsg(struct socket *sock, struct msghdr *m, size_t total_len
908907
if (unlikely(!xs->tx))
909908
return -ENOBUFS;
910909

911-
if (sk_can_busy_loop(sk)) {
912-
if (xs->zc)
913-
__sk_mark_napi_id_once(sk, xsk_pool_get_napi_id(xs->pool));
910+
if (sk_can_busy_loop(sk))
914911
sk_busy_loop(sk, 1); /* only support non-blocking sockets */
915-
}
916912

917913
if (xs->zc && xsk_no_wakeup(sk))
918914
return 0;
@@ -1298,6 +1294,14 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len)
12981294
xs->queue_id = qid;
12991295
xp_add_xsk(xs->pool, xs);
13001296

1297+
if (xs->zc && qid < dev->real_num_rx_queues) {
1298+
struct netdev_rx_queue *rxq;
1299+
1300+
rxq = __netif_get_rx_queue(dev, qid);
1301+
if (rxq->napi)
1302+
__sk_mark_napi_id_once(sk, rxq->napi->napi_id);
1303+
}
1304+
13011305
out_unlock:
13021306
if (err) {
13031307
dev_put(dev);

0 commit comments

Comments
 (0)