* [PATCH bpf] xsk: Add truesize to skb_add_rx_frag().
@ 2024-02-02 16:32 Sebastian Andrzej Siewior
2024-02-05 23:13 ` Maciej Fijalkowski
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Sebastian Andrzej Siewior @ 2024-02-02 16:32 UTC (permalink / raw)
To: bpf
Cc: Björn Töpel, Magnus Karlsson, Maciej Fijalkowski,
Jonathan Lemon, Thomas Gleixner, Sebastian Andrzej Siewior
xsk_build_skb() allocates a page and adds it to the skb via
skb_add_rx_frag() and specifies 0 for truesize. This leads to a warning
in skb_add_rx_frag() with CONFIG_DEBUG_NET enabled because size is
larger than truesize.
Increasing truesize requires to add the same amount to socket's
sk_wmem_alloc counter in order not to underflow the counter during
release in the destructor (sock_wfree()).
Pass the size of the allocated page as truesize to skb_add_rx_frag().
Add this mount to socket's sk_wmem_alloc counter.
Fixes: cf24f5a5feea ("xsk: add support for AF_XDP multi-buffer on Tx path")
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
Noticed by running test_xsk.sh
net/xdp/xsk.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index 0348e4bde23b2..3050739cfe1e0 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -744,7 +744,8 @@ static struct sk_buff *xsk_build_skb(struct xdp_sock *xs,
memcpy(vaddr, buffer, len);
kunmap_local(vaddr);
- skb_add_rx_frag(skb, nr_frags, page, 0, len, 0);
+ skb_add_rx_frag(skb, nr_frags, page, 0, len, PAGE_SIZE);
+ refcount_add(PAGE_SIZE, &xs->sk.sk_wmem_alloc);
}
if (first_frag && desc->options & XDP_TX_METADATA) {
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH bpf] xsk: Add truesize to skb_add_rx_frag().
2024-02-02 16:32 [PATCH bpf] xsk: Add truesize to skb_add_rx_frag() Sebastian Andrzej Siewior
@ 2024-02-05 23:13 ` Maciej Fijalkowski
2024-02-13 15:37 ` Sebastian Andrzej Siewior
2024-02-13 22:20 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 6+ messages in thread
From: Maciej Fijalkowski @ 2024-02-05 23:13 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: bpf, Björn Töpel, Magnus Karlsson, Jonathan Lemon,
Thomas Gleixner
On Fri, Feb 02, 2024 at 05:32:20PM +0100, Sebastian Andrzej Siewior wrote:
> xsk_build_skb() allocates a page and adds it to the skb via
> skb_add_rx_frag() and specifies 0 for truesize. This leads to a warning
> in skb_add_rx_frag() with CONFIG_DEBUG_NET enabled because size is
> larger than truesize.
>
> Increasing truesize requires to add the same amount to socket's
> sk_wmem_alloc counter in order not to underflow the counter during
> release in the destructor (sock_wfree()).
>
> Pass the size of the allocated page as truesize to skb_add_rx_frag().
> Add this mount to socket's sk_wmem_alloc counter.
>
> Fixes: cf24f5a5feea ("xsk: add support for AF_XDP multi-buffer on Tx path")
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Thanks a lot! Of course fix is totally correct.
Acked-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> ---
> Noticed by running test_xsk.sh
>
> net/xdp/xsk.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
> index 0348e4bde23b2..3050739cfe1e0 100644
> --- a/net/xdp/xsk.c
> +++ b/net/xdp/xsk.c
> @@ -744,7 +744,8 @@ static struct sk_buff *xsk_build_skb(struct xdp_sock *xs,
> memcpy(vaddr, buffer, len);
> kunmap_local(vaddr);
>
> - skb_add_rx_frag(skb, nr_frags, page, 0, len, 0);
> + skb_add_rx_frag(skb, nr_frags, page, 0, len, PAGE_SIZE);
> + refcount_add(PAGE_SIZE, &xs->sk.sk_wmem_alloc);
> }
>
> if (first_frag && desc->options & XDP_TX_METADATA) {
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH bpf] xsk: Add truesize to skb_add_rx_frag().
2024-02-02 16:32 [PATCH bpf] xsk: Add truesize to skb_add_rx_frag() Sebastian Andrzej Siewior
2024-02-05 23:13 ` Maciej Fijalkowski
@ 2024-02-13 15:37 ` Sebastian Andrzej Siewior
2024-02-13 15:59 ` Maciej Fijalkowski
2024-02-13 22:20 ` patchwork-bot+netdevbpf
2 siblings, 1 reply; 6+ messages in thread
From: Sebastian Andrzej Siewior @ 2024-02-13 15:37 UTC (permalink / raw)
To: bpf
Cc: Björn Töpel, Magnus Karlsson, Maciej Fijalkowski,
Jonathan Lemon, Thomas Gleixner
On 2024-02-02 17:32:20 [+0100], To bpf@vger.kernel.org wrote:
> xsk_build_skb() allocates a page and adds it to the skb via
> skb_add_rx_frag() and specifies 0 for truesize. This leads to a warning
> in skb_add_rx_frag() with CONFIG_DEBUG_NET enabled because size is
> larger than truesize.
>
> Increasing truesize requires to add the same amount to socket's
> sk_wmem_alloc counter in order not to underflow the counter during
> release in the destructor (sock_wfree()).
>
> Pass the size of the allocated page as truesize to skb_add_rx_frag().
> Add this mount to socket's sk_wmem_alloc counter.
>
> Fixes: cf24f5a5feea ("xsk: add support for AF_XDP multi-buffer on Tx path")
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Is this stuck somewhere or just waiting for review/ etc?
Patchwork says new and the ci failure on s390x seems unrelated.
Sebastian
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH bpf] xsk: Add truesize to skb_add_rx_frag().
2024-02-13 15:37 ` Sebastian Andrzej Siewior
@ 2024-02-13 15:59 ` Maciej Fijalkowski
2024-02-13 16:02 ` Sebastian Andrzej Siewior
0 siblings, 1 reply; 6+ messages in thread
From: Maciej Fijalkowski @ 2024-02-13 15:59 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: bpf, Björn Töpel, Magnus Karlsson, Jonathan Lemon,
Thomas Gleixner, daniel, ast, andrii
On Tue, Feb 13, 2024 at 04:37:37PM +0100, Sebastian Andrzej Siewior wrote:
> On 2024-02-02 17:32:20 [+0100], To bpf@vger.kernel.org wrote:
> > xsk_build_skb() allocates a page and adds it to the skb via
> > skb_add_rx_frag() and specifies 0 for truesize. This leads to a warning
> > in skb_add_rx_frag() with CONFIG_DEBUG_NET enabled because size is
> > larger than truesize.
> >
> > Increasing truesize requires to add the same amount to socket's
> > sk_wmem_alloc counter in order not to underflow the counter during
> > release in the destructor (sock_wfree()).
> >
> > Pass the size of the allocated page as truesize to skb_add_rx_frag().
> > Add this mount to socket's sk_wmem_alloc counter.
> >
> > Fixes: cf24f5a5feea ("xsk: add support for AF_XDP multi-buffer on Tx path")
> > Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
>
> Is this stuck somewhere or just waiting for review/ etc?
> Patchwork says new and the ci failure on s390x seems unrelated.
I acked it week ago or so, maybe bpf maintainers missed it as I don't see
them being CCed? Adding in now.
>
> Sebastian
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH bpf] xsk: Add truesize to skb_add_rx_frag().
2024-02-13 15:59 ` Maciej Fijalkowski
@ 2024-02-13 16:02 ` Sebastian Andrzej Siewior
0 siblings, 0 replies; 6+ messages in thread
From: Sebastian Andrzej Siewior @ 2024-02-13 16:02 UTC (permalink / raw)
To: Maciej Fijalkowski
Cc: bpf, Björn Töpel, Magnus Karlsson, Jonathan Lemon,
Thomas Gleixner, daniel, ast, andrii
On 2024-02-13 16:59:13 [+0100], Maciej Fijalkowski wrote:
> I acked it week ago or so, maybe bpf maintainers missed it as I don't see
> them being CCed? Adding in now.
Thank you. They did not pop up on get_maintainer so I did not add them.
Sebastian
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH bpf] xsk: Add truesize to skb_add_rx_frag().
2024-02-02 16:32 [PATCH bpf] xsk: Add truesize to skb_add_rx_frag() Sebastian Andrzej Siewior
2024-02-05 23:13 ` Maciej Fijalkowski
2024-02-13 15:37 ` Sebastian Andrzej Siewior
@ 2024-02-13 22:20 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-02-13 22:20 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: bpf, bjorn, magnus.karlsson, maciej.fijalkowski, jonathan.lemon,
tglx
Hello:
This patch was applied to bpf/bpf.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:
On Fri, 2 Feb 2024 17:32:20 +0100 you wrote:
> xsk_build_skb() allocates a page and adds it to the skb via
> skb_add_rx_frag() and specifies 0 for truesize. This leads to a warning
> in skb_add_rx_frag() with CONFIG_DEBUG_NET enabled because size is
> larger than truesize.
>
> Increasing truesize requires to add the same amount to socket's
> sk_wmem_alloc counter in order not to underflow the counter during
> release in the destructor (sock_wfree()).
>
> [...]
Here is the summary with links:
- [bpf] xsk: Add truesize to skb_add_rx_frag().
https://git.kernel.org/bpf/bpf/c/2127c6043836
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] 6+ messages in thread
end of thread, other threads:[~2024-02-13 22:20 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-02 16:32 [PATCH bpf] xsk: Add truesize to skb_add_rx_frag() Sebastian Andrzej Siewior
2024-02-05 23:13 ` Maciej Fijalkowski
2024-02-13 15:37 ` Sebastian Andrzej Siewior
2024-02-13 15:59 ` Maciej Fijalkowski
2024-02-13 16:02 ` Sebastian Andrzej Siewior
2024-02-13 22:20 ` 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