Skip to content

Commit 8da7bea

Browse files
JasonXingPaolo Abeni
authored andcommitted
xsk: add indirect call for xsk_destruct_skb
Since Eric proposed an idea about adding indirect call wrappers for UDP and managed to see a huge improvement[1], the same situation can also be applied in xsk scenario. This patch adds an indirect call for xsk and helps current copy mode improve the performance by around 1% stably which was observed with IXGBE at 10Gb/sec loaded. If the throughput grows, the positive effect will be magnified. I applied this patch on top of batch xmit series[2], and was able to see <5% improvement from our internal application which is a little bit unstable though. Use INDIRECT wrappers to keep xsk_destruct_skb static as it used to be when the mitigation config is off. Be aware of the freeing path that can be very hot since the frequency can reach around 2,000,000 times per second with the xdpsock test. [1]: https://lore.kernel.org/netdev/[email protected]/ [2]: https://lore.kernel.org/all/[email protected]/ Suggested-by: Alexander Lobakin <[email protected]> Signed-off-by: Jason Xing <[email protected]> Reviewed-by: Alexander Lobakin <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent b981e10 commit 8da7bea

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

include/net/xdp_sock.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ struct xsk_tx_metadata_ops {
125125
int xsk_generic_rcv(struct xdp_sock *xs, struct xdp_buff *xdp);
126126
int __xsk_map_redirect(struct xdp_sock *xs, struct xdp_buff *xdp);
127127
void __xsk_map_flush(struct list_head *flush_list);
128+
INDIRECT_CALLABLE_DECLARE(void xsk_destruct_skb(struct sk_buff *));
128129

129130
/**
130131
* xsk_tx_metadata_to_compl - Save enough relevant metadata information
@@ -218,6 +219,12 @@ static inline void __xsk_map_flush(struct list_head *flush_list)
218219
{
219220
}
220221

222+
#ifdef CONFIG_MITIGATION_RETPOLINE
223+
static inline void xsk_destruct_skb(struct sk_buff *skb)
224+
{
225+
}
226+
#endif
227+
221228
static inline void xsk_tx_metadata_to_compl(struct xsk_tx_metadata *meta,
222229
struct xsk_tx_metadata_compl *compl)
223230
{

net/core/skbuff.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
#include <net/page_pool/helpers.h>
8282
#include <net/psp/types.h>
8383
#include <net/dropreason.h>
84+
#include <net/xdp_sock.h>
8485

8586
#include <linux/uaccess.h>
8687
#include <trace/events/skb.h>
@@ -1140,12 +1141,13 @@ void skb_release_head_state(struct sk_buff *skb)
11401141
if (skb->destructor) {
11411142
DEBUG_NET_WARN_ON_ONCE(in_hardirq());
11421143
#ifdef CONFIG_INET
1143-
INDIRECT_CALL_3(skb->destructor,
1144+
INDIRECT_CALL_4(skb->destructor,
11441145
tcp_wfree, __sock_wfree, sock_wfree,
1146+
xsk_destruct_skb,
11451147
skb);
11461148
#else
1147-
INDIRECT_CALL_1(skb->destructor,
1148-
sock_wfree,
1149+
INDIRECT_CALL_2(skb->destructor,
1150+
sock_wfree, xsk_destruct_skb,
11491151
skb);
11501152

11511153
#endif

net/xdp/xsk.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,8 @@ static u32 xsk_get_num_desc(struct sk_buff *skb)
602602
return XSKCB(skb)->num_descs;
603603
}
604604

605-
static void xsk_destruct_skb(struct sk_buff *skb)
605+
INDIRECT_CALLABLE_SCOPE
606+
void xsk_destruct_skb(struct sk_buff *skb)
606607
{
607608
struct xsk_tx_metadata_compl *compl = &skb_shinfo(skb)->xsk_meta;
608609

0 commit comments

Comments
 (0)