lkml.org 
[lkml]   [2021]   [Dec]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [RFC 05/12] net: optimise page get/free for bvec zc
From
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@gmail.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

\
 
 \ /
  Last update: 2021-12-01 21:19    [W:0.046 / U:0.188 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site