2024-04-04 06:00:13

by Song, Xiongwei

[permalink] [raw]
Subject: [PATCH v2 0/3] SLUB: improve filling cpu partial a bit in get_partial_node()

From: Xiongwei Song <[email protected]>

This series is to remove the unnecessary check for filling cpu partial
and improve the readability.

Introduce slub_get_cpu_partial() and dummy function to remove #ifdef of
CONFIG_SLUB_CPU_PARTIAL. Please check patch 2 and patch 3.

Also add the comparison in patch 3 for when breaking from filling cpu
partial loop with ">" or ">=". For more details, please check the
patch 3 inside.

No functionality changed.

Changes in v2:
- Refine the commit message(from Vlastimil Babka's comments).
- Refine the check conditions of filling cpu partial(as Vlastimil Babka
suggested).
- drop patch 4 of v1.

v1:
- https://lore.kernel.org/lkml/[email protected]/T/

Before v1:
- Actually, the series is the improvement of patch below:
https://lore.kernel.org/lkml/[email protected]/T/

Regards,
Xiongwei

Xiongwei Song (3):
mm/slub: remove the check of !kmem_cache_has_cpu_partial()
mm/slub: add slub_get_cpu_partial() helper
mm/slub: simplify get_partial_node()

mm/slub.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)

--
2.34.1



2024-04-04 06:13:06

by Song, Xiongwei

[permalink] [raw]
Subject: [PATCH v2 2/3] mm/slub: add slub_get_cpu_partial() helper

From: Xiongwei Song <[email protected]>

Add slub_get_cpu_partial() and dummy function to help improve
get_partial_node(). It can help remove #ifdef of CONFIG_SLUB_CPU_PARTIAL
and improve filling cpu partial logic.

Signed-off-by: Xiongwei Song <[email protected]>
---
mm/slub.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/mm/slub.c b/mm/slub.c
index 059922044a4f..590cc953895d 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -604,11 +604,21 @@ static void slub_set_cpu_partial(struct kmem_cache *s, unsigned int nr_objects)
nr_slabs = DIV_ROUND_UP(nr_objects * 2, oo_objects(s->oo));
s->cpu_partial_slabs = nr_slabs;
}
+
+static inline unsigned int slub_get_cpu_partial(struct kmem_cache *s)
+{
+ return s->cpu_partial_slabs;
+}
#else
static inline void
slub_set_cpu_partial(struct kmem_cache *s, unsigned int nr_objects)
{
}
+
+static inline unsigned int slub_get_cpu_partial(struct kmem_cache *s)
+{
+ return 0;
+}
#endif /* CONFIG_SLUB_CPU_PARTIAL */

/*
--
2.34.1