* Re: [PATCH] net: eliminate meaningless memcpy to data in pskb_carve_inside_nonlinear()
@ 2020-08-11 12:10 linmiaohe
2020-08-11 15:35 ` Eric Dumazet
0 siblings, 1 reply; 6+ messages in thread
From: linmiaohe @ 2020-08-11 12:10 UTC (permalink / raw)
To: Eric Dumazet
Cc: davem, kuba, pshelar, martin.varghese, fw, dcaratti, edumazet,
steffen.klassert, pabeni, shmulik, kyk.segfault, netdev,
linux-kernel
Eric Dumazet <eric.dumazet@gmail.com> wrote:
> 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.
>>
>
>Reminder : net-next is CLOSED.
>
Thanks for your remind. I would wait for it open.
>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;
>
This looks good. Will send a patch v2 soon. May I add a suggested-by tag of you ?
Many thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net: eliminate meaningless memcpy to data in pskb_carve_inside_nonlinear()
2020-08-11 12:10 [PATCH] net: eliminate meaningless memcpy to data in pskb_carve_inside_nonlinear() linmiaohe
@ 2020-08-11 15:35 ` Eric Dumazet
0 siblings, 0 replies; 6+ messages in thread
From: Eric Dumazet @ 2020-08-11 15:35 UTC (permalink / raw)
To: linmiaohe, Eric Dumazet
Cc: davem, kuba, pshelar, martin.varghese, fw, dcaratti, edumazet,
steffen.klassert, pabeni, shmulik, kyk.segfault, netdev,
linux-kernel
On 8/11/20 5:10 AM, linmiaohe wrote:
> Eric Dumazet <eric.dumazet@gmail.com> wrote:
>> 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.
>>>
>>
>> Reminder : net-next is CLOSED.
>>
>
> Thanks for your remind. I would wait for it open.
>
>> 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;
>>
>
> This looks good. Will send a patch v2 soon. May I add a suggested-by tag of you ?
I would advise not using Suggested-by, as this would imply I suggested the idea of changing
this function in the first place.
I will add a Reviewed-by: eventually if your v2 submission looks fine to me.
Thanks.
> Many thanks.
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net: eliminate meaningless memcpy to data in pskb_carve_inside_nonlinear()
@ 2020-08-11 11:54 linmiaohe
0 siblings, 0 replies; 6+ messages in thread
From: linmiaohe @ 2020-08-11 11:54 UTC (permalink / raw)
To: Florian Westphal
Cc: davem, kuba, pshelar, martin.varghese, dcaratti, edumazet,
steffen.klassert, pabeni, shmulik, kyk.segfault, netdev,
linux-kernel
Florian Westphal <fw@strlen.de> wrote:
>Miaohe Lin <linmiaohe@huawei.com> wrote:
>> The skb_shared_info part of the data is assigned in the following loop.
>
>Where?
>
It's at the below for (i = 0; i < nfrags; i++) loop. But I missed something as Eric Dumazet pointed out.
Sorry about it.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net: eliminate meaningless memcpy to data in pskb_carve_inside_nonlinear()
2020-08-10 12:28 Miaohe Lin
2020-08-10 13:56 ` Florian Westphal
@ 2020-08-10 15:06 ` Eric Dumazet
1 sibling, 0 replies; 6+ messages in thread
From: Eric Dumazet @ 2020-08-10 15:06 UTC (permalink / raw)
To: Miaohe Lin, davem, kuba, pshelar, martin.varghese, fw, dcaratti,
edumazet, steffen.klassert, pabeni, shmulik, kyk.segfault
Cc: netdev, linux-kernel
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;
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] net: eliminate meaningless memcpy to data in pskb_carve_inside_nonlinear()
2020-08-10 12:28 Miaohe Lin
@ 2020-08-10 13:56 ` Florian Westphal
2020-08-10 15:06 ` Eric Dumazet
1 sibling, 0 replies; 6+ messages in thread
From: Florian Westphal @ 2020-08-10 13:56 UTC (permalink / raw)
To: Miaohe Lin
Cc: davem, kuba, pshelar, martin.varghese, fw, dcaratti, edumazet,
steffen.klassert, pabeni, shmulik, kyk.segfault, netdev,
linux-kernel
Miaohe Lin <linmiaohe@huawei.com> wrote:
> The skb_shared_info part of the data is assigned in the following loop.
Where?
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] net: eliminate meaningless memcpy to data in pskb_carve_inside_nonlinear()
@ 2020-08-10 12:28 Miaohe Lin
2020-08-10 13:56 ` Florian Westphal
2020-08-10 15:06 ` Eric Dumazet
0 siblings, 2 replies; 6+ messages in thread
From: Miaohe Lin @ 2020-08-10 12:28 UTC (permalink / raw)
To: davem, kuba, pshelar, martin.varghese, fw, dcaratti, edumazet,
steffen.klassert, pabeni, shmulik, kyk.segfault
Cc: netdev, linux-kernel, linmiaohe
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;
--
2.19.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-08-11 15:35 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-11 12:10 [PATCH] net: eliminate meaningless memcpy to data in pskb_carve_inside_nonlinear() linmiaohe
2020-08-11 15:35 ` Eric Dumazet
-- strict thread matches above, loose matches on Subject: below --
2020-08-11 11:54 linmiaohe
2020-08-10 12:28 Miaohe Lin
2020-08-10 13:56 ` Florian Westphal
2020-08-10 15:06 ` Eric Dumazet
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).