From d39c28aafe4457dd892598afc737622409526aca Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Tue, 10 Dec 2024 15:10:04 -0500 Subject: [PATCH] slub: More optimistic sheaf return vbabka notes: this may not be universal win, needs evaluation Namely it can return half-filled sheaf to the barn's full list. Signed-off-by: Liam R. Howlett --- mm/slub.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index a03cf92718d1..acff36201439 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -5021,11 +5021,18 @@ void kmem_cache_return_sheaf(struct kmem_cache *s, gfp_t gfp, struct slab_sheaf *sheaf) { struct slub_percpu_sheaves *pcs; - bool refill = false; + bool keep = false; struct node_barn *barn; //TODO: handle oversize sheaf + /* Assume it will be kept */ + if (!sheaf->size && refill_sheaf(s, sheaf, gfp)) { + sheaf_flush(s, sheaf); + free_empty_sheaf(s, sheaf); + return; + } + pcs = cpu_sheaves_lock(s->cpu_sheaves); if (!pcs->spare) { @@ -5034,7 +5041,7 @@ void kmem_cache_return_sheaf(struct kmem_cache *s, gfp_t gfp, } else if (pcs->barn->nr_full >= MAX_FULL_SHEAVES) { /* racy check */ barn = pcs->barn; - refill = true; + keep = true; } cpu_sheaves_unlock(s->cpu_sheaves); @@ -5042,11 +5049,8 @@ void kmem_cache_return_sheaf(struct kmem_cache *s, gfp_t gfp, if (!sheaf) return; - /* - * if the barn is full of full sheaves or we fail to refill the sheaf, - * simply flush and free it - */ - if (!refill || refill_sheaf(s, sheaf, gfp)) { + /* if the barn is full, simply flush and free it */ + if (!keep) { sheaf_flush(s, sheaf); free_empty_sheaf(s, sheaf); return; -- 2.49.0