From ae46aadc78810923af852128621b4b9f466acffa 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 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 89480ba75fef..1907a21c232a 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -4987,11 +4987,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) { @@ -5000,7 +5007,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); @@ -5008,11 +5015,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.50.1