All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm, slub: Consider rest of partial list if acquire_slab() fails
@ 2020-12-28 13:08 Jann Horn
  2020-12-28 19:05   ` David Rientjes
  2020-12-29  1:10   ` Joonsoo Kim
  0 siblings, 2 replies; 5+ messages in thread
From: Jann Horn @ 2020-12-28 13:08 UTC (permalink / raw)
  To: Christoph Lameter, Pekka Enberg, David Rientjes, Joonsoo Kim,
	Andrew Morton
  Cc: linux-mm, linux-kernel

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.

Fixes: 7ced37197196 ("slub: Acquire_slab() avoid loop")
Signed-off-by: Jann Horn <jannh@google.com>
---
 mm/slub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/slub.c b/mm/slub.c
index 0c8b43a5b3b0..b1777ba06735 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1974,7 +1974,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) {

base-commit: 5c8fe583cce542aa0b84adc939ce85293de36e5e
-- 
2.29.2.729.g45daf8777d-goog


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm, slub: Consider rest of partial list if acquire_slab() fails
  2020-12-28 13:08 [PATCH] mm, slub: Consider rest of partial list if acquire_slab() fails Jann Horn
@ 2020-12-28 19:05   ` David Rientjes
  2020-12-29  1:10   ` Joonsoo Kim
  1 sibling, 0 replies; 5+ messages in thread
From: David Rientjes @ 2020-12-28 19:05 UTC (permalink / raw)
  To: Jann Horn
  Cc: Christoph Lameter, Pekka Enberg, Joonsoo Kim, Andrew Morton,
	linux-mm, linux-kernel

On Mon, 28 Dec 2020, Jann Horn wrote:

> 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.
> 
> Fixes: 7ced37197196 ("slub: Acquire_slab() avoid loop")
> Signed-off-by: Jann Horn <jannh@google.com>

Acked-by: David Rientjes <rientjes@google.com>

Indeed, it looks like commit 7ced37197196 ("slub: Acquire_slab() avoid 
loop") stopped the iteration prematurely.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm, slub: Consider rest of partial list if acquire_slab() fails
@ 2020-12-28 19:05   ` David Rientjes
  0 siblings, 0 replies; 5+ messages in thread
From: David Rientjes @ 2020-12-28 19:05 UTC (permalink / raw)
  To: Jann Horn
  Cc: Christoph Lameter, Pekka Enberg, Joonsoo Kim, Andrew Morton,
	linux-mm, linux-kernel

On Mon, 28 Dec 2020, Jann Horn wrote:

> 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.
> 
> Fixes: 7ced37197196 ("slub: Acquire_slab() avoid loop")
> Signed-off-by: Jann Horn <jannh@google.com>

Acked-by: David Rientjes <rientjes@google.com>

Indeed, it looks like commit 7ced37197196 ("slub: Acquire_slab() avoid 
loop") stopped the iteration prematurely.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm, slub: Consider rest of partial list if acquire_slab() fails
  2020-12-28 13:08 [PATCH] mm, slub: Consider rest of partial list if acquire_slab() fails Jann Horn
@ 2020-12-29  1:10   ` Joonsoo Kim
  2020-12-29  1:10   ` Joonsoo Kim
  1 sibling, 0 replies; 5+ messages in thread
From: Joonsoo Kim @ 2020-12-29  1:10 UTC (permalink / raw)
  To: Jann Horn
  Cc: Christoph Lameter, Pekka Enberg, David Rientjes, Joonsoo Kim,
	Andrew Morton, Linux Memory Management List, LKML

2020년 12월 28일 (월) 오후 10:10, Jann Horn <jannh@google.com>님이 작성:
>
> 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.
>
> Fixes: 7ced37197196 ("slub: Acquire_slab() avoid loop")
> Signed-off-by: Jann Horn <jannh@google.com>

Acked-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>

Thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm, slub: Consider rest of partial list if acquire_slab() fails
@ 2020-12-29  1:10   ` Joonsoo Kim
  0 siblings, 0 replies; 5+ messages in thread
From: Joonsoo Kim @ 2020-12-29  1:10 UTC (permalink / raw)
  To: Jann Horn
  Cc: Christoph Lameter, Pekka Enberg, David Rientjes, Joonsoo Kim,
	Andrew Morton, Linux Memory Management List, LKML

2020년 12월 28일 (월) 오후 10:10, Jann Horn <jannh@google.com>님이 작성:
>
> 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.
>
> Fixes: 7ced37197196 ("slub: Acquire_slab() avoid loop")
> Signed-off-by: Jann Horn <jannh@google.com>

Acked-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>

Thanks.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-12-29  1:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-28 13:08 [PATCH] mm, slub: Consider rest of partial list if acquire_slab() fails Jann Horn
2020-12-28 19:05 ` David Rientjes
2020-12-28 19:05   ` David Rientjes
2020-12-29  1:10 ` Joonsoo Kim
2020-12-29  1:10   ` Joonsoo Kim

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.