]> 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)
committerVlastimil Babka <vbabka@suse.cz>
Mon, 20 Jan 2025 15:25:08 +0000 (16:25 +0100)
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 <Liam.Howlett@Oracle.com>
mm/slub.c

index a03cf92718d1625c61e85032142f6e86fb19e209..acff36201439d65704a091bf2c735017adf2c812 100644 (file)
--- 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;