netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] ftgmac100: fix skb truesize underestimation
@ 2011-10-13 21:30 Eric Dumazet
  2011-10-14  2:25 ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2011-10-13 21:30 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Po-Yu Chuang

ftgmac100 allocates a page per skb fragment. We must account
PAGE_SIZE increments on skb->truesize, not the actual frag length.

If frame is under 64 bytes, page is freed, and truesize adjusted.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Po-Yu Chuang <ratbert@faraday-tech.com>
---
 drivers/net/ethernet/faraday/ftgmac100.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index 54709af..fb5579a 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -467,7 +467,7 @@ static bool ftgmac100_rx_packet(struct ftgmac100 *priv, int *processed)
 
 		skb->len += size;
 		skb->data_len += size;
-		skb->truesize += size;
+		skb->truesize += PAGE_SIZE;
 
 		if (ftgmac100_rxdes_last_segment(rxdes))
 			done = true;
@@ -478,6 +478,8 @@ static bool ftgmac100_rx_packet(struct ftgmac100 *priv, int *processed)
 		rxdes = ftgmac100_current_rxdes(priv);
 	} while (!done);
 
+	if (skb->len <= 64)
+		skb->truesize -= PAGE_SIZE;
 	__pskb_pull_tail(skb, min(skb->len, 64U));
 	skb->protocol = eth_type_trans(skb, netdev);
 

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] ftgmac100: fix skb truesize underestimation
  2011-10-13 21:30 [PATCH net-next] ftgmac100: fix skb truesize underestimation Eric Dumazet
@ 2011-10-14  2:25 ` David Miller
  2011-10-14  3:50   ` Po-Yu Chuang
  0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2011-10-14  2:25 UTC (permalink / raw)
  To: eric.dumazet; +Cc: netdev, ratbert

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Thu, 13 Oct 2011 23:30:52 +0200

> ftgmac100 allocates a page per skb fragment. We must account
> PAGE_SIZE increments on skb->truesize, not the actual frag length.
> 
> If frame is under 64 bytes, page is freed, and truesize adjusted.
> 
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>

Applied.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] ftgmac100: fix skb truesize underestimation
  2011-10-14  2:25 ` David Miller
@ 2011-10-14  3:50   ` Po-Yu Chuang
  0 siblings, 0 replies; 3+ messages in thread
From: Po-Yu Chuang @ 2011-10-14  3:50 UTC (permalink / raw)
  To: David Miller; +Cc: eric.dumazet, netdev, ratbert

Dear Eric and David,

On Fri, Oct 14, 2011 at 10:25 AM, David Miller <davem@davemloft.net> wrote:
> From: Eric Dumazet <eric.dumazet@gmail.com>
> Date: Thu, 13 Oct 2011 23:30:52 +0200
>
>> ftgmac100 allocates a page per skb fragment. We must account
>> PAGE_SIZE increments on skb->truesize, not the actual frag length.
>>
>> If frame is under 64 bytes, page is freed, and truesize adjusted.
>>
>> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
>
> Applied.

Thank you.

best regards,
Po-Yu Chuang

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-10-14  3:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-13 21:30 [PATCH net-next] ftgmac100: fix skb truesize underestimation Eric Dumazet
2011-10-14  2:25 ` David Miller
2011-10-14  3:50   ` Po-Yu Chuang

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).