[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d4ef96a8-94e7-bd9d-b3b9-f4f8e85373e4@gmail.com>
Date: Wed, 1 Dec 2021 20:17:34 +0000
From: Pavel Begunkov <asml.silence@...il.com>
To: Jonathan Lemon <jonathan.lemon@...il.com>
Cc: io-uring@...r.kernel.org, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, Jakub Kicinski <kuba@...nel.org>,
"David S . Miller" <davem@...emloft.net>,
Willem de Bruijn <willemb@...gle.com>,
Eric Dumazet <edumazet@...gle.com>,
Hideaki YOSHIFUJI <yoshfuji@...ux-ipv6.org>,
David Ahern <dsahern@...nel.org>, Jens Axboe <axboe@...nel.dk>
Subject: Re: [RFC 05/12] net: optimise page get/free for bvec zc
On 12/1/21 19:20, Jonathan Lemon wrote:
> On Tue, Nov 30, 2021 at 03:18:53PM +0000, Pavel Begunkov wrote:
>> get_page() in __zerocopy_sg_from_bvec() and matching put_page()s are
>> expensive. However, we can avoid it if the caller can guarantee that
>> pages stay alive until the corresponding ubuf_info is not released.
>> In particular, it targets io_uring with fixed buffers following the
>> described contract.
>>
>> Assuming that nobody yet uses bvec together with zerocopy, make all
>> calls with bvec iterators follow this model.
>>
>> Signed-off-by: Pavel Begunkov <asml.silence@...il.com>
>> ---
[...]
>> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
>> index b23db60ea6f9..b7b087815539 100644
>> --- a/net/core/skbuff.c
>> +++ b/net/core/skbuff.c
>> @@ -666,10 +666,14 @@ static void skb_release_data(struct sk_buff *skb)
>> &shinfo->dataref))
>> goto exit;
>>
>> - skb_zcopy_clear(skb, true);
>> + if (!(shinfo->flags & SKBFL_MANAGED_FRAGS)) {
>> + for (i = 0; i < shinfo->nr_frags; i++)
>> + __skb_frag_unref(&shinfo->frags[i], skb->pp_recycle);
>> + } else {
>> + shinfo->flags &= ~SKBFL_MANAGED_FRAGS;
>> + }
>>
>> - for (i = 0; i < shinfo->nr_frags; i++)
>> - __skb_frag_unref(&shinfo->frags[i], skb->pp_recycle);
>> + skb_zcopy_clear(skb, true);
>
> It would be better if all of this logic was moved into the callback
> under zcopy_clear. Note that this path is called for both TX and RX.
Yeah, can be done and removes the extra if from non-zc path.
Thanks!
--
Pavel Begunkov
Powered by blists - more mailing lists