Skip to content

Commit

Permalink
mm, slub: extract get_partial() from new_slab_objects()
Browse files Browse the repository at this point in the history
The later patches will need more fine grained control over individual actions
in ___slab_alloc(), the only caller of new_slab_objects(), so this is a first
preparatory step with no functional change.

This adds a goto label that appears unnecessary at this point, but will be
useful for later changes.

Signed-off-by: Vlastimil Babka <[email protected]>
Acked-by: Christoph Lameter <[email protected]>
  • Loading branch information
tehcaster committed Sep 3, 2021
1 parent 976b805 commit 2a90490
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions mm/slub.c
Original file line number Diff line number Diff line change
Expand Up @@ -2613,17 +2613,12 @@ slab_out_of_memory(struct kmem_cache *s, gfp_t gfpflags, int nid)
static inline void *new_slab_objects(struct kmem_cache *s, gfp_t flags,
int node, struct kmem_cache_cpu **pc)
{
void *freelist;
void *freelist = NULL;
struct kmem_cache_cpu *c = *pc;
struct page *page;

WARN_ON_ONCE(s->ctor && (flags & __GFP_ZERO));

freelist = get_partial(s, flags, node, c);

if (freelist)
return freelist;

page = new_slab(s, flags, node);
if (page) {
c = raw_cpu_ptr(s->cpu_slab);
Expand Down Expand Up @@ -2787,13 +2782,18 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
goto redo;
}

freelist = get_partial(s, gfpflags, node, c);
if (freelist)
goto check_new_page;

freelist = new_slab_objects(s, gfpflags, node, &c);

if (unlikely(!freelist)) {
slab_out_of_memory(s, gfpflags, node);
return NULL;
}

check_new_page:
page = c->page;
if (likely(!kmem_cache_debug(s) && pfmemalloc_match(page, gfpflags)))
goto load_freelist;
Expand Down

0 comments on commit 2a90490

Please sign in to comment.