瀏覽代碼

SLUB: Don't pass __GFP_FAIL for the initial allocation

SLUB uses higher order allocations by default but falls back to small
orders under memory pressure. Make sure the GFP mask used in the initial
allocation doesn't include __GFP_NOFAIL.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Pekka Enberg 16 年之前
父節點
當前提交
ba52270d18
共有 1 個文件被更改,包括 8 次插入2 次删除
  1. 8 2
      mm/slub.c

+ 8 - 2
mm/slub.c

@@ -1085,11 +1085,17 @@ static struct page *allocate_slab(struct kmem_cache *s, gfp_t flags, int node)
 {
 {
 	struct page *page;
 	struct page *page;
 	struct kmem_cache_order_objects oo = s->oo;
 	struct kmem_cache_order_objects oo = s->oo;
+	gfp_t alloc_gfp;
 
 
 	flags |= s->allocflags;
 	flags |= s->allocflags;
 
 
-	page = alloc_slab_page(flags | __GFP_NOWARN | __GFP_NORETRY, node,
-									oo);
+	/*
+	 * Let the initial higher-order allocation fail under memory pressure
+	 * so we fall-back to the minimum order allocation.
+	 */
+	alloc_gfp = (flags | __GFP_NOWARN | __GFP_NORETRY) & ~__GFP_NOFAIL;
+
+	page = alloc_slab_page(alloc_gfp, node, oo);
 	if (unlikely(!page)) {
 	if (unlikely(!page)) {
 		oo = s->min;
 		oo = s->min;
 		/*
 		/*