net, gro: fix the truesize of all fragments
Subsystems (2)
RFC PATCH 1/1 net, gro: fix the truesize of all fragments
From: Zhi Yong Wu <[email protected]>
When the truesize of all fragments was calculated, it didn't take the first small piece of data into account.
--- net/core/skbuff.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)
net/core/skbuff.c +7 -3
@@ -3027,9 +3027,12 @@ int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb) frag->page_offset += offset;skb_frag_size_sub (frag, offset); -/* all fragments truesize : remove (head size + sk_buff) */ +/** +* all fragments truesize : +* remove (head size + sk_buff + offset) +*/ delta_truesize = skb->truesize - -SKB_TRUESIZE (skb_end_offset (skb)); +SKB_TRUESIZE (skb_end_offset (skb) + offset); skb->truesize -= skb->data_len; skb->len -= skb->data_len;
@@ -3060,7 +3063,8 @@ int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb)memcpy (frag +1 , skbinfo->frags,sizeof (*frag) * skbinfo->nr_frags);/* We dont need to clear skbinfo->nr_frags here */ - delta_truesize = skb->truesize -SKB_DATA_ALIGN (sizeof (struct sk_buff )); + delta_truesize = skb->truesize - +SKB_DATA_ALIGN (sizeof (struct sk_buff )) - offset;NAPI_GRO_CB (skb)->free =NAPI_GRO_FREE_STOLEN_HEAD ; goto done; }
Signature · 1 line
1.7.6.5
Hello.
Quoted 15 lines · Zhi Yong Wu
From: Zhi Yong Wu <[email protected]>
When the truesize of all fragments was calculated, it didn't take the first small piece of data into account.
Signed-off-by Zhi Yong Wu <[email protected]>--- net/core/skbuff.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)net/core/skbuff.c +0
-0
net/core/skbuff.c int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb) · line 3030
Quoted 5 lines
net/core/skbuff.c +1
-1@@ -3027,9 +3027,12 @@ int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb) frag->page_offset += offset;skb_frag_size_sub (frag, offset); -/* all fragments truesize : remove (head size + sk_buff) */ +/**
Why kernel-doc style comment here? Networking code uses the following
comment style:
/* bla
* bla
*/
net/core/skbuff.c int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb) · line 3038
Quoted 9 lines
net/core/skbuff.c +4
-1+* all fragments truesize : +* remove (head size + sk_buff + offset) +*/ delta_truesize = skb->truesize - -SKB_TRUESIZE (skb_end_offset (skb)); +SKB_TRUESIZE (skb_end_offset (skb) + offset); skb->truesize -= skb->data_len; skb->len -= skb->data_len;
WBR, Sergei
Quoted 35 lines · Sergei Shtylyov
Hello.
Quoted 18 lines · Zhi Yong Wu
From: Zhi Yong Wu <[email protected]>
When the truesize of all fragments was calculated, it didn't take the first small piece of data into account.
Signed-off-by Zhi Yong Wu <[email protected]>--- net/core/skbuff.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)net/core/skbuff.c +0
-0net/core/skbuff.c int skb_gro_receive(struct sk_buff **head, struct · line 3032
Quoted 7 lines
net/core/skbuff.c +1
-1@@ -3027,9 +3027,12 @@ int skb_gro_receive(struct sk_buff **head, structsk_buff *skb) frag->page_offset += offset; skb_frag_size_sub(frag, offset); -/* all fragments truesize : remove (head size + sk_buff) */ +/** Why kernel-doc style comment here? Networking code uses the following
comment style:
Quoted 3 lines
/* bla
* bla
*/
No, If you check other comments in networking code, you will see why i did as that.
/**
* skb_segment - Perform protocol segmentation on skb. * @skb: buffer to segment * @features: features for the output path (see dev->features) * * This function performs segmentation on the given skb. It returns * a pointer to the first in a list of new skbs for the segments. * In case of error it returns ERR_PTR(err).
*/
struct sk_buff *skb_segment
Quoted 10 lines
Quoted 10 lines
net/core/skbuff.c +4
-1+* all fragments truesize : +* remove (head size + sk_buff + offset) +*/ delta_truesize = skb->truesize - -SKB_TRUESIZE (skb_end_offset (skb)); +SKB_TRUESIZE (skb_end_offset (skb) + offset);
Quoted 5 lines
Quoted 2 lines
skb->truesize -= skb->data_len; skb->len -= skb->data_len;WBR, Sergei
Sorry, what is WBR?
Quoted 1 line
Signature · 3 lines
Regards, Zhi Yong Wu
Hello.
Quoted 26 lines · Zhi Yong Wu
Quoted 25 lines
Quoted 15 lines
From: Zhi Yong Wu <[email protected]>
When the truesize of all fragments was calculated, it didn't take the first small piece of data into account.
Signed-off-by Zhi Yong Wu <[email protected]>--- net/core/skbuff.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)net/core/skbuff.c +0
-0net/core/skbuff.c int skb_gro_receive(struct sk_buff **head, struct · line 3032
Quoted 7 lines
net/core/skbuff.c +1
-1@@ -3027,9 +3027,12 @@ int skb_gro_receive(struct sk_buff **head, structsk_buff *skb) frag->page_offset += offset; skb_frag_size_sub(frag, offset); -/* all fragments truesize : remove (head size + sk_buff) */ +/** Why kernel-doc style comment here? Networking code uses the following
comment style:
Quoted 5 lines
Quoted 3 lines
/* bla
* bla
*/No, If you check other comments in networking code,
I suggest you do this, and not only comments before functions but also
inside them. I also suggest that you read chapter 8 of Documentation/CodingStyle.
Quoted 2 lines
you will see why i
did as that.
I repeat, this is kernel-doc style comment, that is used to comment on a
functions/structures, and then can be automatically processed to create kernel documentation. Your case does not fit for /** comment.
Quoted 19 lines
/**
* skb_segment - Perform protocol segmentation on skb. * @skb: buffer to segment * @features: features for the output path (see dev->features) * * This function performs segmentation on the given skb. It returns * a pointer to the first in a list of new skbs for the segments. * In case of error it returns ERR_PTR(err).*/
structsk_buff*skb_segmentQuoted 8 lines
Quoted 8 lines
net/core/skbuff.c +4
-1+* all fragments truesize : +* remove (head size + sk_buff + offset) +*/ delta_truesize = skb->truesize - -SKB_TRUESIZE (skb_end_offset (skb)); +SKB_TRUESIZE (skb_end_offset (skb) + offset);
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
skb->truesize -= skb->data_len; skb->len -= skb->data_len;WBR, Sergei
Sorry, what is WBR?
With best regards. Nothing offensive. :-)
WBR, Sergei
Quoted 49 lines · Sergei Shtylyov
Hello.
Quoted 31 lines · Zhi Yong Wu
Quoted 29 lines
Quoted 18 lines
From: Zhi Yong Wu <[email protected]>
When the truesize of all fragments was calculated, it didn't take the first small piece of data into account.
Signed-off-by Zhi Yong Wu <[email protected]>--- net/core/skbuff.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)net/core/skbuff.c +0
-0net/core/skbuff.c int skb_gro_receive(struct sk_buff **head, struct · line 3032
Quoted 7 lines
net/core/skbuff.c +1
-1@@ -3027,9 +3027,12 @@ int skb_gro_receive(struct sk_buff **head, structsk_buff *skb) frag->page_offset += offset; skb_frag_size_sub(frag, offset); -/* all fragments truesize : remove (head size + sk_buff) */ +/** Why kernel-doc style comment here? Networking code uses the following
comment style:Quoted 6 lines
Quoted 3 lines
/* bla
* bla
*/No, If you check other comments in networking code,
I suggest you do this, and not only comments before functions but also
inside them. I also suggest that you read chapter 8 ofDocumentation/CodingStyle.
Quoted 7 lines
Quoted 2 lines
you will see why i
did as that.I repeat, this is kernel-doc style comment, that is used to comment on a
functions/structures, and then can be automatically processed to create kernel documentation. Your case does not fit for /** comment.
Your explanation is very clear, i accept your advice, thanks.
Quoted 37 lines
Quoted 27 lines
/**
* skb_segment - Perform protocol segmentation on skb. * @skb: buffer to segment * @features: features for the output path (see dev->features) * * This function performs segmentation on the given skb. It returns * a pointer to the first in a list of new skbs for the segments. * In case of error it returns ERR_PTR(err).*/
structsk_buff*skb_segmentQuoted 13 lines
Quoted 10 lines
net/core/skbuff.c +4
-1+* all fragments truesize : +* remove (head size + sk_buff + offset) +*/ delta_truesize = skb->truesize - -SKB_TRUESIZE (skb_end_offset (skb)); +SKB_TRUESIZE (skb_end_offset (skb) + offset);skb->truesize -= skb->data_len; skb->len -= skb->data_len;Quoted 4 lines
Quoted 1 line
WBR, Sergei
Sorry, what is WBR?
With best regards. Nothing offensive. :-)
WBR, Sergei
Signature · 3 lines
Regards, Zhi Yong Wu
Quoted 30 lines · Zhi Yong Wu
From: Zhi Yong Wu <[email protected]>
When the truesize of all fragments was calculated, it didn't take the first small piece of data into account.
Signed-off-by Zhi Yong Wu <[email protected]>--- net/core/skbuff.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)net/core/skbuff.c +5
-2@@ -3027,9 +3027,12 @@ int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb) frag->page_offset += offset;skb_frag_size_sub (frag, offset); -/* all fragments truesize : remove (head size + sk_buff) */ +/** +* all fragments truesize : +* remove (head size + sk_buff + offset) +*/ delta_truesize = skb->truesize - -SKB_TRUESIZE (skb_end_offset (skb)); +SKB_TRUESIZE (skb_end_offset (skb) + offset); skb->truesize -= skb->data_len; skb->len -= skb->data_len;
net/core/skbuff.c int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb) · line 3070
Quoted 9 lines
net/core/skbuff.c +2
-1@@ -3060,7 +3063,8 @@ int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb)memcpy (frag +1 , skbinfo->frags,sizeof (*frag) * skbinfo->nr_frags);/* We dont need to clear skbinfo->nr_frags here */ - delta_truesize = skb->truesize -SKB_DATA_ALIGN (sizeof (struct sk_buff )); + delta_truesize = skb->truesize - +SKB_DATA_ALIGN (sizeof (struct sk_buff )) - offset;NAPI_GRO_CB (skb)->free =NAPI_GRO_FREE_STOLEN_HEAD ; goto done; }
Nope, this patch is not needed.
truesize is about tracking the memory we allocated, not the memory we really use.
What exact issue do you have ? I suspect a bug in a driver.
Quoted 44 lines · Eric Dumazet
Quoted 30 lines · Zhi Yong Wu
From: Zhi Yong Wu <[email protected]>
When the truesize of all fragments was calculated, it didn't take the first small piece of data into account.
Signed-off-by Zhi Yong Wu <[email protected]>--- net/core/skbuff.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)net/core/skbuff.c +5
-2@@ -3027,9 +3027,12 @@ int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb) frag->page_offset += offset;skb_frag_size_sub (frag, offset); -/* all fragments truesize : remove (head size + sk_buff) */ +/** +* all fragments truesize : +* remove (head size + sk_buff + offset) +*/ delta_truesize = skb->truesize - -SKB_TRUESIZE (skb_end_offset (skb)); +SKB_TRUESIZE (skb_end_offset (skb) + offset); skb->truesize -= skb->data_len; skb->len -= skb->data_len;net/core/skbuff.c int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb) · line 3070
Quoted 9 lines
net/core/skbuff.c +2
-1@@ -3060,7 +3063,8 @@ int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb)memcpy (frag +1 , skbinfo->frags,sizeof (*frag) * skbinfo->nr_frags);/* We dont need to clear skbinfo->nr_frags here */ - delta_truesize = skb->truesize -SKB_DATA_ALIGN (sizeof (struct sk_buff )); + delta_truesize = skb->truesize - +SKB_DATA_ALIGN (sizeof (struct sk_buff )) - offset;NAPI_GRO_CB (skb)->free =NAPI_GRO_FREE_STOLEN_HEAD ; goto done; }Nope, this patch is not needed.
Quoted 2 lines
truesize is about tracking the memory we allocated, not the memory we really use.
wow, i forgot this, thanks for yor reminder.
Quoted 2 lines
What exact issue do you have ? I suspect a bug in a driver.
I didn't hit any issue, but found this when i read gro related code. a but in a driver? sorry, i don't know, look forward to seeing your fix.
Quoted 3 lines
Signature · 3 lines
Regards, Zhi Yong Wu
Quoted 11 lines · Zhi Yong Wu
Quoted 4 lines · Eric Dumazet
Nope, this patch is not needed.
truesize is about tracking the memory we allocated, not the memory we really use.
wow, i forgot this, thanks for yor reminder.
Quoted 2 lines
What exact issue do you have ? I suspect a bug in a driver.
I didn't hit any issue, but found this when i read gro related code. a but in a driver? sorry, i don't know, look forward to seeing your fix.
No, I have no particular issue with this code, I thought you had a problem on a running machine.
If you found this by code review, then everything is fine, and no patch is needed at this point.
Thanks