diff options
| author | Eric Dumazet <eric.dumazet@gmail.com> | 2012-04-10 16:30:48 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2012-04-11 10:11:12 -0400 |
| commit | a21d45726acacc963d8baddf74607d9b74e2b723 (patch) | |
| tree | 7cd7e1409ac0242148a0a8117956d08572eb32cf /include/linux | |
| parent | 87151b8689d890dfb495081f7be9b9e257f7a2df (diff) | |
tcp: avoid order-1 allocations on wifi and tx path
Marc Merlin reported many order-1 allocations failures in TX path on its
wireless setup, that dont make any sense with MTU=1500 network, and non
SG capable hardware.
After investigation, it turns out TCP uses sk_stream_alloc_skb() and
used as a convention skb_tailroom(skb) to know how many bytes of data
payload could be put in this skb (for non SG capable devices)
Note : these skb used kmalloc-4096 (MTU=1500 + MAX_HEADER +
sizeof(struct skb_shared_info) being above 2048)
Later, mac80211 layer need to add some bytes at the tail of skb
(IEEE80211_ENCRYPT_TAILROOM = 18 bytes) and since no more tailroom is
available has to call pskb_expand_head() and request order-1
allocations.
This patch changes sk_stream_alloc_skb() so that only
sk->sk_prot->max_header bytes of headroom are reserved, and use a new
skb field, avail_size to hold the data payload limit.
This way, order-0 allocations done by TCP stack can leave more than 2 KB
of tailroom and no more allocation is performed in mac80211 layer (or
any layer needing some tailroom)
avail_size is unioned with mark/dropcount, since mark will be set later
in IP stack for output packets. Therefore, skb size is unchanged.
Reported-by: Marc MERLIN <marc@merlins.org>
Tested-by: Marc MERLIN <marc@merlins.org>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/skbuff.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 33370271b8b2..70a3f8d49118 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h | |||
| @@ -481,6 +481,7 @@ struct sk_buff { | |||
| 481 | union { | 481 | union { |
| 482 | __u32 mark; | 482 | __u32 mark; |
| 483 | __u32 dropcount; | 483 | __u32 dropcount; |
| 484 | __u32 avail_size; | ||
| 484 | }; | 485 | }; |
| 485 | 486 | ||
| 486 | sk_buff_data_t transport_header; | 487 | sk_buff_data_t transport_header; |
| @@ -1366,6 +1367,18 @@ static inline int skb_tailroom(const struct sk_buff *skb) | |||
| 1366 | } | 1367 | } |
| 1367 | 1368 | ||
| 1368 | /** | 1369 | /** |
| 1370 | * skb_availroom - bytes at buffer end | ||
| 1371 | * @skb: buffer to check | ||
| 1372 | * | ||
| 1373 | * Return the number of bytes of free space at the tail of an sk_buff | ||
| 1374 | * allocated by sk_stream_alloc() | ||
| 1375 | */ | ||
| 1376 | static inline int skb_availroom(const struct sk_buff *skb) | ||
| 1377 | { | ||
| 1378 | return skb_is_nonlinear(skb) ? 0 : skb->avail_size - skb->len; | ||
| 1379 | } | ||
| 1380 | |||
| 1381 | /** | ||
| 1369 | * skb_reserve - adjust headroom | 1382 | * skb_reserve - adjust headroom |
| 1370 | * @skb: buffer to alter | 1383 | * @skb: buffer to alter |
| 1371 | * @len: bytes to move | 1384 | * @len: bytes to move |
