]>
Commit | Line | Data |
---|---|---|
da495922 GKH |
1 | From foo@baz Fri Jul 3 19:59:52 PDT 2015 |
2 | From: Shaohua Li <shli@fb.com> | |
3 | Date: Thu, 11 Jun 2015 16:50:48 -0700 | |
4 | Subject: net: don't wait for order-3 page allocation | |
5 | ||
6 | From: Shaohua Li <shli@fb.com> | |
7 | ||
8 | [ Upstream commit fb05e7a89f500cfc06ae277bdc911b281928995d ] | |
9 | ||
10 | We saw excessive direct memory compaction triggered by skb_page_frag_refill. | |
11 | This causes performance issues and add latency. Commit 5640f7685831e0 | |
12 | introduces the order-3 allocation. According to the changelog, the order-3 | |
13 | allocation isn't a must-have but to improve performance. But direct memory | |
14 | compaction has high overhead. The benefit of order-3 allocation can't | |
15 | compensate the overhead of direct memory compaction. | |
16 | ||
17 | This patch makes the order-3 page allocation atomic. If there is no memory | |
18 | pressure and memory isn't fragmented, the alloction will still success, so we | |
19 | don't sacrifice the order-3 benefit here. If the atomic allocation fails, | |
20 | direct memory compaction will not be triggered, skb_page_frag_refill will | |
21 | fallback to order-0 immediately, hence the direct memory compaction overhead is | |
22 | avoided. In the allocation failure case, kswapd is waken up and doing | |
23 | compaction, so chances are allocation could success next time. | |
24 | ||
25 | alloc_skb_with_frags is the same. | |
26 | ||
27 | The mellanox driver does similar thing, if this is accepted, we must fix | |
28 | the driver too. | |
29 | ||
30 | V3: fix the same issue in alloc_skb_with_frags as pointed out by Eric | |
31 | V2: make the changelog clearer | |
32 | ||
33 | Cc: Eric Dumazet <edumazet@google.com> | |
34 | Cc: Chris Mason <clm@fb.com> | |
35 | Cc: Debabrata Banerjee <dbavatar@gmail.com> | |
36 | Signed-off-by: Shaohua Li <shli@fb.com> | |
37 | Acked-by: Eric Dumazet <edumazet@google.com> | |
38 | Signed-off-by: David S. Miller <davem@davemloft.net> | |
39 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
40 | --- | |
41 | net/core/skbuff.c | 2 +- | |
42 | net/core/sock.c | 2 +- | |
43 | 2 files changed, 2 insertions(+), 2 deletions(-) | |
44 | ||
45 | --- a/net/core/skbuff.c | |
46 | +++ b/net/core/skbuff.c | |
47 | @@ -4443,7 +4443,7 @@ struct sk_buff *alloc_skb_with_frags(uns | |
48 | ||
49 | while (order) { | |
50 | if (npages >= 1 << order) { | |
51 | - page = alloc_pages(gfp_mask | | |
52 | + page = alloc_pages((gfp_mask & ~__GFP_WAIT) | | |
53 | __GFP_COMP | | |
54 | __GFP_NOWARN | | |
55 | __GFP_NORETRY, | |
56 | --- a/net/core/sock.c | |
57 | +++ b/net/core/sock.c | |
58 | @@ -1895,7 +1895,7 @@ bool skb_page_frag_refill(unsigned int s | |
59 | ||
60 | pfrag->offset = 0; | |
61 | if (SKB_FRAG_PAGE_ORDER) { | |
62 | - pfrag->page = alloc_pages(gfp | __GFP_COMP | | |
63 | + pfrag->page = alloc_pages((gfp & ~__GFP_WAIT) | __GFP_COMP | | |
64 | __GFP_NOWARN | __GFP_NORETRY, | |
65 | SKB_FRAG_PAGE_ORDER); | |
66 | if (likely(pfrag->page)) { |