Skip to content

Commit 24c6a09

Browse files
Chengming Zhoutehcaster
authored andcommitted
slub: Reflow ___slab_alloc()
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>
1 parent b85ea95 commit 24c6a09

1 file changed

Lines changed: 15 additions & 16 deletions

File tree

mm/slub.c

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3216,8 +3216,21 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
32163216
pc.slab = &slab;
32173217
pc.orig_size = orig_size;
32183218
freelist = get_partial(s, node, &pc);
3219-
if (freelist)
3220-
goto check_new_slab;
3219+
if (freelist) {
3220+
if (kmem_cache_debug(s)) {
3221+
/*
3222+
* For debug caches here we had to go through
3223+
* alloc_single_from_partial() so just store the
3224+
* tracking info and return the object.
3225+
*/
3226+
if (s->flags & SLAB_STORE_USER)
3227+
set_track(s, freelist, TRACK_ALLOC, addr);
3228+
3229+
return freelist;
3230+
}
3231+
3232+
goto retry_load_slab;
3233+
}
32213234

32223235
slub_put_cpu_ptr(s->cpu_slab);
32233236
slab = new_slab(s, gfpflags, node);
@@ -3253,20 +3266,6 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
32533266

32543267
inc_slabs_node(s, slab_nid(slab), slab->objects);
32553268

3256-
check_new_slab:
3257-
3258-
if (kmem_cache_debug(s)) {
3259-
/*
3260-
* For debug caches here we had to go through
3261-
* alloc_single_from_partial() so just store the tracking info
3262-
* and return the object
3263-
*/
3264-
if (s->flags & SLAB_STORE_USER)
3265-
set_track(s, freelist, TRACK_ALLOC, addr);
3266-
3267-
return freelist;
3268-
}
3269-
32703269
if (unlikely(!pfmemalloc_match(slab, gfpflags))) {
32713270
/*
32723271
* For !pfmemalloc_match() case we don't load freelist so that

0 commit comments

Comments
 (0)