author: Vlastimil Babka <vbabka@suse.cz> 2021-05-11 18:25:09 +0200
committer: Vlastimil Babka <vbabka@suse.cz> 2021-09-04 01:12:20 +0200
commit: 1572df7cbcb48936c880f2d2de524f8e47ab65d4
parent: 75c8ff281d7a6faa650bb9b32052f3ee1b5f8e83
Commit Summary:
Diffstat:
1 file changed, 19 insertions, 6 deletions
diff --git a/mm/slub.c b/mm/slub.c
index e9d582eee7d7..9607ce37e661 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2782,13 +2782,29 @@ new_slab:
c->page = page;
check_new_page:
- if (likely(!kmem_cache_debug(s) && pfmemalloc_match(page, gfpflags)))
- goto load_freelist;
- /* Only entered in the debug case */
- if (kmem_cache_debug(s) &&
- !alloc_debug_processing(s, page, freelist, addr))
- goto new_slab; /* Slab failed checks. Next slab needed */
+ if (kmem_cache_debug(s)) {
+ if (!alloc_debug_processing(s, page, freelist, addr))
+ /* Slab failed checks. Next slab needed */
+ goto new_slab;
+ else
+ /*
+ * For debug case, we don't load freelist so that all
+ * allocations go through alloc_debug_processing()
+ */
+ goto return_single;
+ }
+
+ if (unlikely(!pfmemalloc_match(page, gfpflags)))
+ /*
+ * For !pfmemalloc_match() case we don't load freelist so that
+ * we don't make further mismatched allocations easier.
+ */
+ goto return_single;
+
+ goto load_freelist;
+
+return_single:
deactivate_slab(s, page, get_freepointer(s, freelist), c);
return freelist;