mm-commits.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: akpm@linux-foundation.org, cl@linux.com, iamjoonsoo.kim@lge.com,
	jannh@google.com, linux-mm@kvack.org, mm-commits@vger.kernel.org,
	penberg@kernel.org, rientjes@google.com,
	torvalds@linux-foundation.org
Subject: [patch 01/10] mm, slub: consider rest of partial list if acquire_slab() fails
Date: Tue, 12 Jan 2021 15:49:04 -0800	[thread overview]
Message-ID: <20210112234904.X5Ka1PlfB%akpm@linux-foundation.org> (raw)
In-Reply-To: <20210112154839.abeb6e57de79480059fd9b0e@linux-foundation.org>

From: Jann Horn <jannh@google.com>
Subject: mm, slub: consider rest of partial list if acquire_slab() fails

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>
---

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

--- a/mm/slub.c~mm-slub-consider-rest-of-partial-list-if-acquire_slab-fails
+++ a/mm/slub.c
@@ -1973,7 +1973,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) {
_

  reply	other threads:[~2021-01-13  0:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-12 23:48 incoming Andrew Morton
2021-01-12 23:49 ` Andrew Morton [this message]
2021-01-12 23:49 ` [patch 02/10] mm/page_alloc: add a missing mm_page_alloc_zone_locked() tracepoint Andrew Morton
2021-01-12 23:49 ` [patch 03/10] mm/memcontrol: fix warning in mem_cgroup_page_lruvec() Andrew Morton
2021-01-12 23:49 ` [patch 04/10] arm/kasan: fix the array size of kasan_early_shadow_pte[] Andrew Morton
2021-01-12 23:49 ` [patch 05/10] mm/vmalloc.c: fix potential memory leak Andrew Morton
2021-01-12 23:49 ` [patch 06/10] mm: migrate: initialize err in do_migrate_pages Andrew Morton
2021-01-12 23:49 ` [patch 07/10] mm/hugetlb: fix potential missing huge page size info Andrew Morton
2021-01-12 23:49 ` [patch 08/10] MAINTAINERS: add Vlastimil as slab allocators maintainer Andrew Morton
2021-01-12 23:49 ` [patch 09/10] mm,hwpoison: fix printing of page flags Andrew Morton
2021-01-12 23:49 ` [patch 10/10] mm/process_vm_access.c: include compat.h Andrew Morton
2021-01-15 23:32 ` incoming Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210112234904.X5Ka1PlfB%akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=jannh@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mm-commits@vger.kernel.org \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).