From: linmiaohe <linmiaohe@huawei.com>
To: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Cc: David Miller <davem@davemloft.net>,
Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>,
Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
"Jakub Kicinski" <kuba@kernel.org>,
Network Development <netdev@vger.kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] net: correct zerocopy refcnt with newly allocated UDP or RAW uarg
Date: Fri, 14 Aug 2020 08:17:16 +0000 [thread overview]
Message-ID: <84f3ed74e9de4422933bc6a642890697@huawei.com> (raw)
Willem de Bruijn <willemdebruijn.kernel@gmail.com> wrote:
>On Thu, Aug 13, 2020 at 1:59 PM Miaohe Lin <linmiaohe@huawei.com> wrote:
>>
>> The var extra_uref is introduced to pass the initial reference taken
>> in sock_zerocopy_alloc to the first generated skb. But now we may fail
>> to pass the initial reference with newly allocated UDP or RAW uarg
>> when the skb is zcopied.
>
>extra_uref is true if there is no previous skb to append to or there is a previous skb, but that does not have zerocopy data associated yet (because the previous call(s) did not set MSG_ZEROCOPY).
>
>In other words, when first (allocating and) associating a zerocopy struct with the skb.
Many thanks for your explaination. The var extra_uref plays the role as you say. I just borrowed the description of var extra_uref from previous commit log here.
>
>> - extra_uref = !skb_zcopy(skb); /* only ref on new uarg */
>> + /* Only ref on newly allocated uarg. */
>> + if (!skb_zcopy(skb) || (sk->sk_type != SOCK_STREAM && skb_zcopy(skb) != uarg))
>> + extra_uref = true;
>
>SOCK_STREAM does not use __ip_append_data.
>
>This leaves as new branch skb_zcopy(skb) && skb_zcopy(skb) != uarg.
>
>This function can only acquire a uarg through sock_zerocopy_realloc, which on skb_zcopy(skb) only returns the existing uarg or NULL (for not SOCK_STREAM).
>
>So I don't see when that condition can happen.
>
On skb_zcopy(skb), we returns the existing uarg iff (uarg->id + uarg->len == atomic_read(&sk->sk_zckey)) in sock_zerocopy_realloc. So we may get a newly allocated
uarg via sock_zerocopy_alloc(). Though we may not trigger this codepath now, it's still a potential problem that we may missed the right trace to uarg.
Or am I still miss anything? Thanks.
next reply other threads:[~2020-08-14 8:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-14 8:17 linmiaohe [this message]
2020-08-14 15:44 ` [PATCH] net: correct zerocopy refcnt with newly allocated UDP or RAW uarg Willem de Bruijn
-- strict thread matches above, loose matches on Subject: below --
2020-08-15 2:02 linmiaohe
2020-08-13 11:58 Miaohe Lin
2020-08-13 12:34 ` Willem de Bruijn
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=84f3ed74e9de4422933bc6a642890697@huawei.com \
--to=linmiaohe@huawei.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=kuznet@ms2.inr.ac.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=willemdebruijn.kernel@gmail.com \
--cc=yoshfuji@linux-ipv6.org \
/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;
as well as URLs for NNTP newsgroup(s).