lkml.org 
[lkml]   [2021]   [Jan]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.4 68/76] mm, slub: consider rest of partial list if acquire_slab() fails
    Date
    From: Jann Horn <jannh@google.com>

    commit 8ff60eb052eeba95cfb3efe16b08c9199f8121cf upstream.

    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/20201228130853.1871516-1-jannh@google.com
    Fixes: 7ced37197196 ("slub: Acquire_slab() avoid loop")
    Signed-off-by: Jann Horn <jannh@google.com>
    Acked-by: David Rientjes <rientjes@google.com>
    Acked-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
    Cc: Christoph Lameter <cl@linux.com>
    Cc: Pekka Enberg <penberg@kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    ---
    mm/slub.c | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)

    --- a/mm/slub.c
    +++ b/mm/slub.c
    @@ -1887,7 +1887,7 @@ static void *get_partial_node(struct kme

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

    available += objects;
    if (!object) {

    \
     
     \ /
      Last update: 2021-01-18 12:52    [W:4.224 / U:0.236 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site