Skip to content

Commit ad2df86

Browse files
Chengming Zhougregkh
authored andcommitted
slub: Reflow ___slab_alloc()
[ Upstream commit 24c6a09 ] 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> Stable-dep-of: 850470a ("mm: slub: avoid wake up kswapd in set_track_prepare") Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c866c40 commit ad2df86

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
@@ -3228,8 +3228,21 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
32283228
pc.slab = &slab;
32293229
pc.orig_size = orig_size;
32303230
freelist = get_partial(s, node, &pc);
3231-
if (freelist)
3232-
goto check_new_slab;
3231+
if (freelist) {
3232+
if (kmem_cache_debug(s)) {
3233+
/*
3234+
* For debug caches here we had to go through
3235+
* alloc_single_from_partial() so just store the
3236+
* tracking info and return the object.
3237+
*/
3238+
if (s->flags & SLAB_STORE_USER)
3239+
set_track(s, freelist, TRACK_ALLOC, addr);
3240+
3241+
return freelist;
3242+
}
3243+
3244+
goto retry_load_slab;
3245+
}
32333246

32343247
slub_put_cpu_ptr(s->cpu_slab);
32353248
slab = new_slab(s, gfpflags, node);
@@ -3265,20 +3278,6 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
32653278

32663279
inc_slabs_node(s, slab_nid(slab), slab->objects);
32673280

3268-
check_new_slab:
3269-
3270-
if (kmem_cache_debug(s)) {
3271-
/*
3272-
* For debug caches here we had to go through
3273-
* alloc_single_from_partial() so just store the tracking info
3274-
* and return the object
3275-
*/
3276-
if (s->flags & SLAB_STORE_USER)
3277-
set_track(s, freelist, TRACK_ALLOC, addr);
3278-
3279-
return freelist;
3280-
}
3281-
32823281
if (unlikely(!pfmemalloc_match(slab, gfpflags))) {
32833282
/*
32843283
* For !pfmemalloc_match() case we don't load freelist so that

0 commit comments

Comments
 (0)