* [PATCH net-next v2 0/2] xsk: respect the offsets when copying frags
@ 2025-04-26 8:12 Bui Quang Minh
2025-04-26 8:12 ` [PATCH net-next v2 1/2] " Bui Quang Minh
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Bui Quang Minh @ 2025-04-26 8:12 UTC (permalink / raw)
To: netdev
Cc: Alexei Starovoitov, Daniel Borkmann, David S. Miller,
Jakub Kicinski, Jesper Dangaard Brouer, John Fastabend,
Eric Dumazet, Paolo Abeni, Simon Horman, Maciej Fijalkowski,
Alexander Lobakin, bpf, linux-kernel, Bui Quang Minh
Hi everyone,
In commit 560d958c6c68 ("xsk: add generic XSk &xdp_buff -> skb
conversion"), we introduce a helper to convert zerocopy xdp_buff to skb.
However, in the frag copy, we mistakenly ignore the frag's offset. This
series adds the missing offset when copying frags in
xdp_copy_frags_from_zc(). This function is not used anywhere so no
backport is needed.
This series also makes xdp_copy_frags_from_zc() use page allocation API
page_pool_dev_alloc() instead of page_pool_dev_alloc_netmem() to avoid
possible confusion of the returned value.
Thanks,
Quang Minh.
Bui Quang Minh (2):
xsk: respect the offsets when copying frags
xsk: convert xdp_copy_frags_from_zc() to use page_pool_dev_alloc()
net/core/xdp.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net-next v2 1/2] xsk: respect the offsets when copying frags
2025-04-26 8:12 [PATCH net-next v2 0/2] xsk: respect the offsets when copying frags Bui Quang Minh
@ 2025-04-26 8:12 ` Bui Quang Minh
2025-04-26 8:12 ` [PATCH net-next v2 2/2] xsk: convert xdp_copy_frags_from_zc() to use page_pool_dev_alloc() Bui Quang Minh
2025-04-29 21:40 ` [PATCH net-next v2 0/2] xsk: respect the offsets when copying frags patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Bui Quang Minh @ 2025-04-26 8:12 UTC (permalink / raw)
To: netdev
Cc: Alexei Starovoitov, Daniel Borkmann, David S. Miller,
Jakub Kicinski, Jesper Dangaard Brouer, John Fastabend,
Eric Dumazet, Paolo Abeni, Simon Horman, Maciej Fijalkowski,
Alexander Lobakin, bpf, linux-kernel, Bui Quang Minh
In commit 560d958c6c68 ("xsk: add generic XSk &xdp_buff -> skb
conversion"), we introduce a helper to convert zerocopy xdp_buff to skb.
However, in the frag copy, we mistakenly ignore the frag's offset. This
commit adds the missing offset when copying frags in
xdp_copy_frags_from_zc(). This function is not used anywhere so no
backport is needed.
Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com>
---
net/core/xdp.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/net/core/xdp.c b/net/core/xdp.c
index ea819764ae39..89111c68e545 100644
--- a/net/core/xdp.c
+++ b/net/core/xdp.c
@@ -698,7 +698,8 @@ static noinline bool xdp_copy_frags_from_zc(struct sk_buff *skb,
nr_frags = xinfo->nr_frags;
for (u32 i = 0; i < nr_frags; i++) {
- u32 len = skb_frag_size(&xinfo->frags[i]);
+ const skb_frag_t *frag = &xinfo->frags[i];
+ u32 len = skb_frag_size(frag);
u32 offset, truesize = len;
netmem_ref netmem;
@@ -708,8 +709,8 @@ static noinline bool xdp_copy_frags_from_zc(struct sk_buff *skb,
return false;
}
- memcpy(__netmem_address(netmem),
- __netmem_address(xinfo->frags[i].netmem),
+ memcpy(__netmem_address(netmem) + offset,
+ __netmem_address(frag->netmem) + skb_frag_off(frag),
LARGEST_ALIGN(len));
__skb_fill_netmem_desc_noacc(sinfo, i, netmem, offset, len);
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH net-next v2 2/2] xsk: convert xdp_copy_frags_from_zc() to use page_pool_dev_alloc()
2025-04-26 8:12 [PATCH net-next v2 0/2] xsk: respect the offsets when copying frags Bui Quang Minh
2025-04-26 8:12 ` [PATCH net-next v2 1/2] " Bui Quang Minh
@ 2025-04-26 8:12 ` Bui Quang Minh
2025-04-29 21:40 ` [PATCH net-next v2 0/2] xsk: respect the offsets when copying frags patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Bui Quang Minh @ 2025-04-26 8:12 UTC (permalink / raw)
To: netdev
Cc: Alexei Starovoitov, Daniel Borkmann, David S. Miller,
Jakub Kicinski, Jesper Dangaard Brouer, John Fastabend,
Eric Dumazet, Paolo Abeni, Simon Horman, Maciej Fijalkowski,
Alexander Lobakin, bpf, linux-kernel, Bui Quang Minh
This commit makes xdp_copy_frags_from_zc() use page allocation API
page_pool_dev_alloc() instead of page_pool_dev_alloc_netmem() to avoid
possible confusion of the returned value.
Suggested-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com>
---
net/core/xdp.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/net/core/xdp.c b/net/core/xdp.c
index 89111c68e545..4e91c7790671 100644
--- a/net/core/xdp.c
+++ b/net/core/xdp.c
@@ -701,21 +701,21 @@ static noinline bool xdp_copy_frags_from_zc(struct sk_buff *skb,
const skb_frag_t *frag = &xinfo->frags[i];
u32 len = skb_frag_size(frag);
u32 offset, truesize = len;
- netmem_ref netmem;
+ struct page *page;
- netmem = page_pool_dev_alloc_netmem(pp, &offset, &truesize);
- if (unlikely(!netmem)) {
+ page = page_pool_dev_alloc(pp, &offset, &truesize);
+ if (unlikely(!page)) {
sinfo->nr_frags = i;
return false;
}
- memcpy(__netmem_address(netmem) + offset,
- __netmem_address(frag->netmem) + skb_frag_off(frag),
+ memcpy(page_address(page) + offset,
+ skb_frag_page(frag) + skb_frag_off(frag),
LARGEST_ALIGN(len));
- __skb_fill_netmem_desc_noacc(sinfo, i, netmem, offset, len);
+ __skb_fill_page_desc_noacc(sinfo, i, page, offset, len);
tsize += truesize;
- pfmemalloc |= netmem_is_pfmemalloc(netmem);
+ pfmemalloc |= page_is_pfmemalloc(page);
}
xdp_update_skb_shared_info(skb, nr_frags, xinfo->xdp_frags_size,
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next v2 0/2] xsk: respect the offsets when copying frags
2025-04-26 8:12 [PATCH net-next v2 0/2] xsk: respect the offsets when copying frags Bui Quang Minh
2025-04-26 8:12 ` [PATCH net-next v2 1/2] " Bui Quang Minh
2025-04-26 8:12 ` [PATCH net-next v2 2/2] xsk: convert xdp_copy_frags_from_zc() to use page_pool_dev_alloc() Bui Quang Minh
@ 2025-04-29 21:40 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-04-29 21:40 UTC (permalink / raw)
To: Bui Quang Minh
Cc: netdev, ast, daniel, davem, kuba, hawk, john.fastabend, edumazet,
pabeni, horms, maciej.fijalkowski, aleksander.lobakin, bpf,
linux-kernel
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Sat, 26 Apr 2025 15:12:18 +0700 you wrote:
> Hi everyone,
>
> In commit 560d958c6c68 ("xsk: add generic XSk &xdp_buff -> skb
> conversion"), we introduce a helper to convert zerocopy xdp_buff to skb.
> However, in the frag copy, we mistakenly ignore the frag's offset. This
> series adds the missing offset when copying frags in
> xdp_copy_frags_from_zc(). This function is not used anywhere so no
> backport is needed.
>
> [...]
Here is the summary with links:
- [net-next,v2,1/2] xsk: respect the offsets when copying frags
https://git.kernel.org/netdev/net-next/c/ebaebc5eaf43
- [net-next,v2,2/2] xsk: convert xdp_copy_frags_from_zc() to use page_pool_dev_alloc()
https://git.kernel.org/netdev/net-next/c/7ead4405e06f
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-04-29 21:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-26 8:12 [PATCH net-next v2 0/2] xsk: respect the offsets when copying frags Bui Quang Minh
2025-04-26 8:12 ` [PATCH net-next v2 1/2] " Bui Quang Minh
2025-04-26 8:12 ` [PATCH net-next v2 2/2] xsk: convert xdp_copy_frags_from_zc() to use page_pool_dev_alloc() Bui Quang Minh
2025-04-29 21:40 ` [PATCH net-next v2 0/2] xsk: respect the offsets when copying frags patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox