netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] myri10ge: fix truesize underestimation
@ 2011-10-20 20:10 Eric Dumazet
  2011-10-20 20:33 ` Jon Mason
  2011-10-20 21:42 ` David Miller
  0 siblings, 2 replies; 9+ messages in thread
From: Eric Dumazet @ 2011-10-20 20:10 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Jon Mason

skb->truesize must account for allocated memory, not the used part of
it. Doing this work is important to avoid unexpected OOM situations.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Jon Mason <mason@myri.com>
---
 drivers/net/ethernet/myricom/myri10ge/myri10ge.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
index c970a48..0778edc 100644
--- a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
+++ b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
@@ -1210,7 +1210,6 @@ myri10ge_rx_skb_build(struct sk_buff *skb, u8 * va,
 	struct skb_frag_struct *skb_frags;
 
 	skb->len = skb->data_len = len;
-	skb->truesize = len + sizeof(struct sk_buff);
 	/* attach the page(s) */
 
 	skb_frags = skb_shinfo(skb)->frags;
@@ -1385,6 +1384,8 @@ myri10ge_rx_done(struct myri10ge_slice_state *ss, int len, __wsum csum,
 	if (skb_frag_size(&skb_shinfo(skb)->frags[0]) <= 0) {
 		skb_frag_unref(skb, 0);
 		skb_shinfo(skb)->nr_frags = 0;
+	} else {
+		skb->truesize += bytes * skb_shinfo(skb)->nr_frags;
 	}
 	skb->protocol = eth_type_trans(skb, dev);
 	skb_record_rx_queue(skb, ss - &mgp->ss[0]);

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

end of thread, other threads:[~2011-10-20 21:42 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-20 20:10 [PATCH net-next] myri10ge: fix truesize underestimation Eric Dumazet
2011-10-20 20:33 ` Jon Mason
2011-10-20 20:44   ` Eric Dumazet
2011-10-20 20:45     ` Andrew Gallatin
2011-10-20 20:59       ` Eric Dumazet
2011-10-20 21:03         ` David Miller
2011-10-20 21:04         ` Andrew Gallatin
2011-10-20 21:06           ` Eric Dumazet
2011-10-20 21:42 ` David Miller

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