Skip to content

Commit

Permalink
mm, slub: consider rest of partial list if acquire_slab() fails
Browse files Browse the repository at this point in the history
acquire_slab() fails if there is contention on the freelist of the page
(probably because some other CPU is concurrently freeing an object from
the page).  In that case, it might make sense to look for a different page
(since there might be more remote frees to the page from other CPUs, and
we don't want contention on struct page).

However, the current code accidentally stops looking at the partial list
completely in that case.  Especially on kernels without CONFIG_NUMA set,
this means that get_partial() fails and new_slab_objects() falls back to
new_slab(), allocating new pages.  This could lead to an unnecessary
increase in memory fragmentation.

Link: https://lkml.kernel.org/r/[email protected]
Fixes: 7ced371 ("slub: Acquire_slab() avoid loop")
Signed-off-by: Jann Horn <[email protected]>
Acked-by: David Rientjes <[email protected]>
Acked-by: Joonsoo Kim <[email protected]>
Cc: Christoph Lameter <[email protected]>
Cc: Pekka Enberg <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
thejh authored and torvalds committed Jan 13, 2021
1 parent e609571 commit 8ff60eb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mm/slub.c
Original file line number Diff line number Diff line change
Expand Up @@ -1973,7 +1973,7 @@ static void *get_partial_node(struct kmem_cache *s, struct kmem_cache_node *n,

t = acquire_slab(s, n, page, object == NULL, &objects);
if (!t)
break;
continue; /* cmpxchg raced */

available += objects;
if (!object) {
Expand Down

0 comments on commit 8ff60eb

Please sign in to comment.