summaryrefslogtreecommitdiffstats
path: root/mm/slub.c
diff options
context:
space:
mode:
authorChengming Zhou <zhouchengming@bytedance.com>2023-11-02 03:23:26 +0000
committerVlastimil Babka <vbabka@suse.cz>2023-12-04 17:55:29 +0100
commit213094b5d1af7e6ab294a6d8f3b50cafb72642ae (patch)
treefacfa7a199a9120ca7a6e9ff21b0ef1405b5a492 /mm/slub.c
parent422e7d54375889484b66962d1dcbc392a6bd9e7a (diff)
downloadlinux-213094b5d1af7e6ab294a6d8f3b50cafb72642ae.tar.gz
linux-213094b5d1af7e6ab294a6d8f3b50cafb72642ae.tar.bz2
linux-213094b5d1af7e6ab294a6d8f3b50cafb72642ae.zip
slub: Introduce freeze_slab()
We will have unfrozen slabs out of the node partial list later, so we need a freeze_slab() function to freeze the partial slab and get its freelist. Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com> Reviewed-by: Vlastimil Babka <vbabka@suse.cz> Tested-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Diffstat (limited to 'mm/slub.c')
-rw-r--r--mm/slub.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/mm/slub.c b/mm/slub.c
index 18f18fbbd97e..253626ef9f37 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3099,6 +3099,33 @@ static inline void *get_freelist(struct kmem_cache *s, struct slab *slab)
}
/*
+ * Freeze the partial slab and return the pointer to the freelist.
+ */
+static inline void *freeze_slab(struct kmem_cache *s, struct slab *slab)
+{
+ struct slab new;
+ unsigned long counters;
+ void *freelist;
+
+ do {
+ freelist = slab->freelist;
+ counters = slab->counters;
+
+ new.counters = counters;
+ VM_BUG_ON(new.frozen);
+
+ new.inuse = slab->objects;
+ new.frozen = 1;
+
+ } while (!slab_update_freelist(s, slab,
+ freelist, counters,
+ NULL, new.counters,
+ "freeze_slab"));
+
+ return freelist;
+}
+
+/*
* Slow path. The lockless freelist is empty or we need to perform
* debugging duties.
*