All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: bpf@vger.kernel.org, "Björn Töpel" <bjorn@kernel.org>,
	"Magnus Karlsson" <magnus.karlsson@intel.com>,
	"Jonathan Lemon" <jonathan.lemon@gmail.com>,
	"Thomas Gleixner" <tglx@linutronix.de>
Subject: Re: [PATCH bpf] xsk: Add truesize to skb_add_rx_frag().
Date: Tue, 6 Feb 2024 00:13:05 +0100	[thread overview]
Message-ID: <ZcFrgRdCRnGUmE+S@boxer> (raw)
In-Reply-To: <20240202163221.2488589-1-bigeasy@linutronix.de>

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
> 

  reply	other threads:[~2024-02-05 23:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZcFrgRdCRnGUmE+S@boxer \
    --to=maciej.fijalkowski@intel.com \
    --cc=bigeasy@linutronix.de \
    --cc=bjorn@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=jonathan.lemon@gmail.com \
    --cc=magnus.karlsson@intel.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.