From: Willem de Bruijn <[email protected]>
To: Pavel Begunkov <[email protected]>,
Willem de Bruijn <[email protected]>,
[email protected], [email protected]
Cc: Jens Axboe <[email protected]>,
"David S . Miller" <[email protected]>,
Jakub Kicinski <[email protected]>,
David Ahern <[email protected]>,
Eric Dumazet <[email protected]>
Subject: Re: [PATCH net-next 3/5] net: batch zerocopy_fill_skb_from_iter accounting
Date: Mon, 01 Jul 2024 14:27:59 -0400 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
Pavel Begunkov wrote:
> On 6/28/24 18:06, Willem de Bruijn wrote:
> > Pavel Begunkov wrote:
> >> Instead of accounting every page range against the socket separately, do
> >> it in batch based on the change in skb->truesize. It's also moved into
> >> __zerocopy_sg_from_iter(), so that zerocopy_fill_skb_from_iter() is
> >> simpler and responsible for setting frags but not the accounting.
> >>
> >> Signed-off-by: Pavel Begunkov <[email protected]>
> >
> > Reviewed-by: Willem de Bruijn <[email protected]>
>
> Thanks for reviews!
>
> >> ---
> >> net/core/datagram.c | 31 ++++++++++++++++++-------------
> >> 1 file changed, 18 insertions(+), 13 deletions(-)
> >>
> >> diff --git a/net/core/datagram.c b/net/core/datagram.c
> >> index 7f7d5da2e406..2b24d69b1e94 100644
> >> --- a/net/core/datagram.c
> >> +++ b/net/core/datagram.c
> >> @@ -610,7 +610,7 @@ int skb_copy_datagram_from_iter(struct sk_buff *skb, int offset,
> >> }
> >> EXPORT_SYMBOL(skb_copy_datagram_from_iter);
> >>
> >> -static int zerocopy_fill_skb_from_iter(struct sock *sk, struct sk_buff *skb,
> >> +static int zerocopy_fill_skb_from_iter(struct sk_buff *skb,
> >> struct iov_iter *from, size_t length)
> >> {
> >> int frag = skb_shinfo(skb)->nr_frags;
> >> @@ -621,7 +621,6 @@ static int zerocopy_fill_skb_from_iter(struct sock *sk, struct sk_buff *skb,
> >> int refs, order, n = 0;
> >> size_t start;
> >> ssize_t copied;
> >> - unsigned long truesize;
> >>
> >> if (frag == MAX_SKB_FRAGS)
> >> return -EMSGSIZE;
> >
> > Does the existing code then incorrectly not unwind sk_wmem_queued_add
> > and sk_mem_charge if returning with error from the second or later
> > loop..
>
> As long as ->truesize matches what's accounted to the socket,
> kfree_skb() -> sock_wfree()/->destructor() should take care of it.
> With sk_mem_charge() I assume __zerocopy_sg_from_iter -> ___pskb_trim()
> should do it, need to look it up, but if not, it sounds like a temporary
> over estimation until the skb is put down. I don't see anything
> concerning. Is that the scenario you're worried about?
Oh indeed. Thanks. I don't see ___pskb_trim adjusting except for the
cases where it calls skb_condese, but neither does it adjust truesize.
So indeed a temporary over estimation until e.g., tcp_wmem_free_skb.
Sounds fine.
next prev parent reply other threads:[~2024-07-01 18:28 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-27 12:59 [PATCH net-next 0/5] zerocopy tx cleanups Pavel Begunkov
2024-06-27 12:59 ` [PATCH net-next 1/5] net: always try to set ubuf in skb_zerocopy_iter_stream Pavel Begunkov
2024-06-28 17:03 ` Willem de Bruijn
2024-06-27 12:59 ` [PATCH net-next 2/5] net: split __zerocopy_sg_from_iter() Pavel Begunkov
2024-06-28 17:03 ` Willem de Bruijn
2024-06-27 12:59 ` [PATCH net-next 3/5] net: batch zerocopy_fill_skb_from_iter accounting Pavel Begunkov
2024-06-28 17:06 ` Willem de Bruijn
2024-07-01 11:11 ` Pavel Begunkov
2024-07-01 18:27 ` Willem de Bruijn [this message]
2024-06-27 12:59 ` [PATCH net-next 4/5] io_uring/net: move charging socket out of zc io_uring Pavel Begunkov
2024-06-28 17:06 ` Willem de Bruijn
2024-06-27 12:59 ` [PATCH net-next 5/5] net: limit scope of a skb_zerocopy_iter_stream var Pavel Begunkov
2024-06-28 17:07 ` Willem de Bruijn
2024-06-28 17:09 ` [PATCH net-next 0/5] zerocopy tx cleanups Jens Axboe
2024-07-02 10:30 ` 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=6682f52fd5a96_4208e294c8@willemb.c.googlers.com.notmuch \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox