diff options
author | Eric Dumazet <edumazet@google.com> | 2012-07-10 06:03:41 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-07-11 02:33:12 -0400 |
commit | b28ba72665356438e3a6e3be365c3c3071496840 (patch) | |
tree | 2cf9ff84993f821cd4819db7dd609db1ccbf38f6 | |
parent | efc73f4bbc238d4f579fb612c04c8e1dd8a82979 (diff) |
IPoIB: fix skb truesize underestimatiom
Or Gerlitz reported triggering of WARN_ON_ONCE(delta < len); in
skb_try_coalesce()
This warning tracks drivers that incorrectly set skb->truesize
IPoIB indeed allocates a full page to store a fragment, but only
accounts in skb->truesize the used part of the page (frame length)
This patch fixes skb truesize underestimation, and
also fixes a performance issue, because RX skbs have not enough tailroom
to allow IP and TCP stacks to pull their header in skb linear part
without an expensive call to pskb_expand_head()
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Or Gerlitz <ogerlitz@mellanox.com>
Cc: Erez Shitrit <erezsh@mellanox.com>
Cc: Shlomo Pongartz <shlomop@mellanox.com>
Cc: Roland Dreier <roland@purestorage.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/infiniband/ulp/ipoib/ipoib_ib.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c index 5c1bc995e560..f10221f40803 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c | |||
@@ -123,7 +123,7 @@ static void ipoib_ud_skb_put_frags(struct ipoib_dev_priv *priv, | |||
123 | 123 | ||
124 | skb_frag_size_set(frag, size); | 124 | skb_frag_size_set(frag, size); |
125 | skb->data_len += size; | 125 | skb->data_len += size; |
126 | skb->truesize += size; | 126 | skb->truesize += PAGE_SIZE; |
127 | } else | 127 | } else |
128 | skb_put(skb, length); | 128 | skb_put(skb, length); |
129 | 129 | ||
@@ -156,14 +156,18 @@ static struct sk_buff *ipoib_alloc_rx_skb(struct net_device *dev, int id) | |||
156 | struct ipoib_dev_priv *priv = netdev_priv(dev); | 156 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
157 | struct sk_buff *skb; | 157 | struct sk_buff *skb; |
158 | int buf_size; | 158 | int buf_size; |
159 | int tailroom; | ||
159 | u64 *mapping; | 160 | u64 *mapping; |
160 | 161 | ||
161 | if (ipoib_ud_need_sg(priv->max_ib_mtu)) | 162 | if (ipoib_ud_need_sg(priv->max_ib_mtu)) { |
162 | buf_size = IPOIB_UD_HEAD_SIZE; | 163 | buf_size = IPOIB_UD_HEAD_SIZE; |
163 | else | 164 | tailroom = 128; /* reserve some tailroom for IP/TCP headers */ |
165 | } else { | ||
164 | buf_size = IPOIB_UD_BUF_SIZE(priv->max_ib_mtu); | 166 | buf_size = IPOIB_UD_BUF_SIZE(priv->max_ib_mtu); |
167 | tailroom = 0; | ||
168 | } | ||
165 | 169 | ||
166 | skb = dev_alloc_skb(buf_size + 4); | 170 | skb = dev_alloc_skb(buf_size + tailroom + 4); |
167 | if (unlikely(!skb)) | 171 | if (unlikely(!skb)) |
168 | return NULL; | 172 | return NULL; |
169 | 173 | ||