From: Eric Dumazet <eric.dumazet@gmail.com>
To: Miaohe Lin <linmiaohe@huawei.com>,
davem@davemloft.net, kuba@kernel.org, pshelar@ovn.org,
martin.varghese@nokia.com, fw@strlen.de, dcaratti@redhat.com,
edumazet@google.com, steffen.klassert@secunet.com,
pabeni@redhat.com, shmulik@metanetworks.com,
kyk.segfault@gmail.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: eliminate meaningless memcpy to data in pskb_carve_inside_nonlinear()
Date: Mon, 10 Aug 2020 08:06:11 -0700 [thread overview]
Message-ID: <fd23f2e0-5cf9-ef66-0c15-b46eac1da609@gmail.com> (raw)
In-Reply-To: <20200810122856.5423-1-linmiaohe@huawei.com>
On 8/10/20 5:28 AM, Miaohe Lin wrote:
> The skb_shared_info part of the data is assigned in the following loop. It
> is meaningless to do a memcpy here.
>
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
> net/core/skbuff.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index 7e2e502ef519..5b983c9472f5 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -5952,9 +5952,6 @@ static int pskb_carve_inside_nonlinear(struct sk_buff *skb, const u32 off,
>
> size = SKB_WITH_OVERHEAD(ksize(data));
>
> - memcpy((struct skb_shared_info *)(data + size),
> - skb_shinfo(skb), offsetof(struct skb_shared_info,
> - frags[skb_shinfo(skb)->nr_frags]));
> if (skb_orphan_frags(skb, gfp_mask)) {
> kfree(data);
> return -ENOMEM;
>
Reminder : net-next is CLOSED.
This is not correct. We still have to copy _something_
Something like :
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 2828f6d5ba898a5e50ccce45589bf1370e474b0f..1c0519426c7ba4b04377fc8054c4223c135879ab 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -5953,8 +5953,8 @@ static int pskb_carve_inside_nonlinear(struct sk_buff *skb, const u32 off,
size = SKB_WITH_OVERHEAD(ksize(data));
memcpy((struct skb_shared_info *)(data + size),
- skb_shinfo(skb), offsetof(struct skb_shared_info,
- frags[skb_shinfo(skb)->nr_frags]));
+ skb_shinfo(skb), offsetof(struct skb_shared_info, frags[0]));
+
if (skb_orphan_frags(skb, gfp_mask)) {
kfree(data);
return -ENOMEM;
next prev parent reply other threads:[~2020-08-10 15:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-10 12:28 [PATCH] net: eliminate meaningless memcpy to data in pskb_carve_inside_nonlinear() Miaohe Lin
2020-08-10 13:56 ` Florian Westphal
2020-08-10 15:06 ` Eric Dumazet [this message]
-- strict thread matches above, loose matches on Subject: below --
2020-08-11 11:54 linmiaohe
2020-08-11 12:10 linmiaohe
2020-08-11 15:35 ` Eric Dumazet
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=fd23f2e0-5cf9-ef66-0c15-b46eac1da609@gmail.com \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=dcaratti@redhat.com \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=kuba@kernel.org \
--cc=kyk.segfault@gmail.com \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.varghese@nokia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pshelar@ovn.org \
--cc=shmulik@metanetworks.com \
--cc=steffen.klassert@secunet.com \
/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).