Messages in this thread | | | Date | Wed, 1 Dec 2021 20:17:34 +0000 | Subject | Re: [RFC 05/12] net: optimise page get/free for bvec zc | From | Pavel Begunkov <> |
| |
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
| |