]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
slub: Reflow ___slab_alloc()
authorChengming Zhou <zhouchengming@bytedance.com>
Thu, 2 Nov 2023 03:23:22 +0000 (03:23 +0000)
committerVlastimil Babka <vbabka@suse.cz>
Mon, 13 Nov 2023 08:32:27 +0000 (09:32 +0100)
The get_partial() interface used in ___slab_alloc() may return a single
object in the "kmem_cache_debug(s)" case, in which we will just return
the "freelist" object.

Move this handling up to prepare for later changes.

And the "pfmemalloc_match()" part is not needed for node partial slab,
since we already check this in the get_partial_node().

Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>
Reviewed-by: Vlastimil Babka <vbabka@suse.cz>
Tested-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
mm/slub.c

index 63d281dfacdbca13ff951a4dcacc031d1b6536c0..0b0fdc8c189ff363386c49d2e8f2f927ea9e30f4 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3216,8 +3216,21 @@ new_objects:
        pc.slab = &slab;
        pc.orig_size = orig_size;
        freelist = get_partial(s, node, &pc);
-       if (freelist)
-               goto check_new_slab;
+       if (freelist) {
+               if (kmem_cache_debug(s)) {
+                       /*
+                        * For debug caches here we had to go through
+                        * alloc_single_from_partial() so just store the
+                        * tracking info and return the object.
+                        */
+                       if (s->flags & SLAB_STORE_USER)
+                               set_track(s, freelist, TRACK_ALLOC, addr);
+
+                       return freelist;
+               }
+
+               goto retry_load_slab;
+       }
 
        slub_put_cpu_ptr(s->cpu_slab);
        slab = new_slab(s, gfpflags, node);
@@ -3253,20 +3266,6 @@ new_objects:
 
        inc_slabs_node(s, slab_nid(slab), slab->objects);
 
-check_new_slab:
-
-       if (kmem_cache_debug(s)) {
-               /*
-                * For debug caches here we had to go through
-                * alloc_single_from_partial() so just store the tracking info
-                * and return the object
-                */
-               if (s->flags & SLAB_STORE_USER)
-                       set_track(s, freelist, TRACK_ALLOC, addr);
-
-               return freelist;
-       }
-
        if (unlikely(!pfmemalloc_match(slab, gfpflags))) {
                /*
                 * For !pfmemalloc_match() case we don't load freelist so that