]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.0.8/net-don-t-wait-for-order-3-page-allocation.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.0.8 / net-don-t-wait-for-order-3-page-allocation.patch
CommitLineData
da495922
GKH
1From foo@baz Fri Jul 3 19:59:52 PDT 2015
2From: Shaohua Li <shli@fb.com>
3Date: Thu, 11 Jun 2015 16:50:48 -0700
4Subject: net: don't wait for order-3 page allocation
5
6From: Shaohua Li <shli@fb.com>
7
8[ Upstream commit fb05e7a89f500cfc06ae277bdc911b281928995d ]
9
10We saw excessive direct memory compaction triggered by skb_page_frag_refill.
11This causes performance issues and add latency. Commit 5640f7685831e0
12introduces the order-3 allocation. According to the changelog, the order-3
13allocation isn't a must-have but to improve performance. But direct memory
14compaction has high overhead. The benefit of order-3 allocation can't
15compensate the overhead of direct memory compaction.
16
17This patch makes the order-3 page allocation atomic. If there is no memory
18pressure and memory isn't fragmented, the alloction will still success, so we
19don't sacrifice the order-3 benefit here. If the atomic allocation fails,
20direct memory compaction will not be triggered, skb_page_frag_refill will
21fallback to order-0 immediately, hence the direct memory compaction overhead is
22avoided. In the allocation failure case, kswapd is waken up and doing
23compaction, so chances are allocation could success next time.
24
25alloc_skb_with_frags is the same.
26
27The mellanox driver does similar thing, if this is accepted, we must fix
28the driver too.
29
30V3: fix the same issue in alloc_skb_with_frags as pointed out by Eric
31V2: make the changelog clearer
32
33Cc: Eric Dumazet <edumazet@google.com>
34Cc: Chris Mason <clm@fb.com>
35Cc: Debabrata Banerjee <dbavatar@gmail.com>
36Signed-off-by: Shaohua Li <shli@fb.com>
37Acked-by: Eric Dumazet <edumazet@google.com>
38Signed-off-by: David S. Miller <davem@davemloft.net>
39Signed-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)) {