[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231017154439.3036608-3-chengming.zhou@linux.dev>
Date: Tue, 17 Oct 2023 15:44:36 +0000
From: chengming.zhou@...ux.dev
To: cl@...ux.com, penberg@...nel.org
Cc: rientjes@...gle.com, iamjoonsoo.kim@....com,
akpm@...ux-foundation.org, vbabka@...e.cz,
roman.gushchin@...ux.dev, 42.hyeyoo@...il.com, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, chengming.zhou@...ux.dev,
Chengming Zhou <zhouchengming@...edance.com>
Subject: [RFC PATCH 2/5] slub: Don't manipulate slab list when used by cpu
From: Chengming Zhou <zhouchengming@...edance.com>
We will change to don't freeze slab when moving it out of node partial
list in the following patch, so we can't rely on the frozen bit to
indicate if we should manipulate the slab list or not.
This patch use the introduced on_partial() helper, which check the
slab->flags that protected by node list_lock, so we can know if the
slab is on the node partial list.
Signed-off-by: Chengming Zhou <zhouchengming@...edance.com>
---
mm/slub.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/mm/slub.c b/mm/slub.c
index e5356ad14951..27eac93baa13 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3636,6 +3636,7 @@ static void __slab_free(struct kmem_cache *s, struct slab *slab,
unsigned long counters;
struct kmem_cache_node *n = NULL;
unsigned long flags;
+ bool on_node_partial;
stat(s, FREE_SLOWPATH);
@@ -3683,6 +3684,7 @@ static void __slab_free(struct kmem_cache *s, struct slab *slab,
*/
spin_lock_irqsave(&n->list_lock, flags);
+ on_node_partial = on_partial(n, slab);
}
}
@@ -3711,6 +3713,15 @@ static void __slab_free(struct kmem_cache *s, struct slab *slab,
return;
}
+ /*
+ * This slab was not on node partial list and not full either,
+ * in which case we shouldn't manipulate its list, early return.
+ */
+ if (!on_node_partial && prior) {
+ spin_unlock_irqrestore(&n->list_lock, flags);
+ return;
+ }
+
if (unlikely(!new.inuse && n->nr_partial >= s->min_partial))
goto slab_empty;
--
2.40.1
Powered by blists - more mailing lists