]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm/slub: Add misc sheaf functions
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Wed, 4 Dec 2024 20:23:35 +0000 (15:23 -0500)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Wed, 4 Dec 2024 20:23:35 +0000 (15:23 -0500)
One was needed for the size of the sheaf, one for refilling the sheaf.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
include/linux/slab.h
mm/slub.c

index a87dc3c6392fe235de2eabe1792df86d40c3bbf9..184e00a7ca53bf13ab0dcdad442572551cfec291 100644 (file)
@@ -823,6 +823,9 @@ void *kmem_cache_alloc_node_noprof(struct kmem_cache *s, gfp_t flags,
 struct slab_sheaf *
 kmem_cache_prefill_sheaf(struct kmem_cache *s, gfp_t gfp, unsigned int count);
 
+void kmem_cache_refill_sheaf(struct kmem_cache *s, gfp_t gfp,
+                struct slab_sheaf *sheaf, unsigned long count);
+
 void kmem_cache_return_sheaf(struct kmem_cache *s, gfp_t gfp,
                                       struct slab_sheaf *sheaf);
 
@@ -831,6 +834,8 @@ void *kmem_cache_alloc_from_sheaf_noprof(struct kmem_cache *cachep, gfp_t gfp,
 #define kmem_cache_alloc_from_sheaf(...)       \
                        alloc_hooks(kmem_cache_alloc_from_sheaf_noprof(__VA_ARGS__))
 
+unsigned int kmem_cache_sheaf_count(struct slab_sheaf *sheaf);
+
 /*
  * These macros allow declaring a kmem_buckets * parameter alongside size, which
  * can be compiled out with CONFIG_SLAB_BUCKETS=n so that a large number of call
index a0e2cb7dfb5173f39f36bea1eb9760c3c1b99dd7..42642c8d88d0118caab479ec85ab70bf5446417e 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -4962,6 +4962,23 @@ kmem_cache_prefill_sheaf(struct kmem_cache *s, gfp_t gfp, unsigned int count)
        return sheaf;
 }
 
+void kmem_cache_refill_sheaf(struct kmem_cache *s, gfp_t gfp,
+                struct slab_sheaf *sheaf, unsigned long count)
+{
+       struct slub_percpu_sheaves *pcs;
+
+       if (!sheaf)
+               return;
+
+       //TODO: handle via oversize sheaf
+       if (count + sheaf->size > s->sheaf_capacity)
+               return;
+
+       //TODO: handle failures
+       refill_sheaf(s, sheaf, gfp);
+       sheaf->size += count;
+}
+
 /*
  * Use this to return a sheaf obtained by kmem_cache_prefill_sheaf()
  * It tries to refill the sheaf back to the cache's sheaf_capacity
@@ -5042,6 +5059,10 @@ out:
        return ret;
 }
 
+unsigned int kmem_cache_sheaf_count(struct slab_sheaf *sheaf)
+{
+       return sheaf->size;
+}
 /*
  * To avoid unnecessary overhead, we pass through large allocation requests
  * directly to the page allocator. We use __GFP_COMP, because we will need to