]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
slub: More optimistic sheaf return
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 10 Dec 2024 20:10:04 +0000 (15:10 -0500)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 17 Jan 2025 20:15:27 +0000 (15:15 -0500)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
mm/slub.c

index 89480ba75fefc4328ed27793d93b795d196352a4..1907a21c232aeaf6cf801d469c7d7f7a0cf68f5b 100644 (file)
--- 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;