summaryrefslogtreecommitdiff
path: root/mm
diff options
context:
space:
mode:
authorVlastimil Babka <vbabka@suse.cz>2021-07-29 15:21:07 +0200
committerSebastian Andrzej Siewior <bigeasy@linutronix.de>2021-07-30 12:52:04 +0200
commitf796f3cd9dc963086efa12ea06ccbdf91b626ff0 (patch)
treed95a25c4ebb46578bcb0c3e62f21432c87d0b480 /mm
parent54157c56644d550993d8403aaed2ddd81cf7d5f6 (diff)
downloadlinux-rt-f796f3cd9dc963086efa12ea06ccbdf91b626ff0.tar.gz
mm, slub: restructure new page checks in ___slab_alloc()
When we allocate slab object from a newly acquired page (from node's partial list or page allocator), we usually also retain the page as a new percpu slab. There are two exceptions - when pfmemalloc status of the page doesn't match our gfp flags, or when the cache has debugging enabled. The current code for these decisions is not easy to follow, so restructure it and add comments. The new structure will also help with the following changes. No functional change. Signed-off-by: Vlastimil Babka <vbabka@suse.cz> Acked-by: Mel Gorman <mgorman@techsingularity.net> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Diffstat (limited to 'mm')
-rw-r--r--mm/slub.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/mm/slub.c b/mm/slub.c
index 92a866adce3d..469aa8155663 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2765,13 +2765,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;