Skip to content

Commit 213094b

Browse files
Chengming Zhoutehcaster
authored andcommitted
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>
1 parent 422e7d5 commit 213094b

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

mm/slub.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3098,6 +3098,33 @@ static inline void *get_freelist(struct kmem_cache *s, struct slab *slab)
30983098
return freelist;
30993099
}
31003100

3101+
/*
3102+
* Freeze the partial slab and return the pointer to the freelist.
3103+
*/
3104+
static inline void *freeze_slab(struct kmem_cache *s, struct slab *slab)
3105+
{
3106+
struct slab new;
3107+
unsigned long counters;
3108+
void *freelist;
3109+
3110+
do {
3111+
freelist = slab->freelist;
3112+
counters = slab->counters;
3113+
3114+
new.counters = counters;
3115+
VM_BUG_ON(new.frozen);
3116+
3117+
new.inuse = slab->objects;
3118+
new.frozen = 1;
3119+
3120+
} while (!slab_update_freelist(s, slab,
3121+
freelist, counters,
3122+
NULL, new.counters,
3123+
"freeze_slab"));
3124+
3125+
return freelist;
3126+
}
3127+
31013128
/*
31023129
* Slow path. The lockless freelist is empty or we need to perform
31033130
* debugging duties.

0 commit comments

Comments
 (0)