diff options
author | zhong jiang <zhongjiang@huawei.com> | 2016-10-07 20:01:19 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-10-07 21:46:29 -0400 |
commit | 6213055f2c068b63078649457391ecea9b489ea3 (patch) | |
tree | bb0c8260b211a968de71a05190155fe76da8c3bf | |
parent | ac34dcd263a3afe9a2e4d58a2d93bb66d700ac7c (diff) |
mm,ksm: add __GFP_HIGH to the allocation in alloc_stable_node()
According to Hugh's suggestion, alloc_stable_node() with GFP_KERNEL can
in rare cases cause a hung task warning.
At present, if alloc_stable_node() allocation fails, two break_cows may
want to allocate a couple of pages, and the issue will come up when free
memory is under pressure.
We fix it by adding __GFP_HIGH to GFP, to grant access to memory
reserves, increasing the likelihood of allocation success.
[akpm@linux-foundation.org: tweak comment]
Link: http://lkml.kernel.org/r/1474354484-58233-1-git-send-email-zhongjiang@huawei.com
Signed-off-by: zhong jiang <zhongjiang@huawei.com>
Suggested-by: Hugh Dickins <hughd@google.com>
Acked-by: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | mm/ksm.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -299,7 +299,12 @@ static inline void free_rmap_item(struct rmap_item *rmap_item) | |||
299 | 299 | ||
300 | static inline struct stable_node *alloc_stable_node(void) | 300 | static inline struct stable_node *alloc_stable_node(void) |
301 | { | 301 | { |
302 | return kmem_cache_alloc(stable_node_cache, GFP_KERNEL); | 302 | /* |
303 | * The allocation can take too long with GFP_KERNEL when memory is under | ||
304 | * pressure, which may lead to hung task warnings. Adding __GFP_HIGH | ||
305 | * grants access to memory reserves, helping to avoid this problem. | ||
306 | */ | ||
307 | return kmem_cache_alloc(stable_node_cache, GFP_KERNEL | __GFP_HIGH); | ||
303 | } | 308 | } |
304 | 309 | ||
305 | static inline void free_stable_node(struct stable_node *stable_node) | 310 | static inline void free_stable_node(struct stable_node *stable_node) |