Skip to content

Commit 31bda71

Browse files
Chengming Zhoutehcaster
authored andcommitted
slub: Update frozen slabs documentations in the source
The current updated scheme (which this series implemented) is: - node partial slabs: PG_Workingset && !frozen - cpu partial slabs: !PG_Workingset && !frozen - cpu slabs: !PG_Workingset && frozen - full slabs: !PG_Workingset && !frozen The most important change is that "frozen" bit is not set for the cpu partial slabs anymore, __slab_free() will grab node list_lock then check by !PG_Workingset that it's not on a node partial list. And the "frozen" bit is still kept for the cpu slabs for performance, since we don't need to grab node list_lock to check whether the PG_Workingset is set or not if the "frozen" bit is set in __slab_free(). Update related documentations and comments in the source. Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com> Tested-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Acked-by: Christoph Lameter (Ampere) <cl@linux.com> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
1 parent 21316fd commit 31bda71

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

mm/slub.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,28 @@
7676
*
7777
* Frozen slabs
7878
*
79-
* If a slab is frozen then it is exempt from list management. It is not
80-
* on any list except per cpu partial list. The processor that froze the
79+
* If a slab is frozen then it is exempt from list management. It is
80+
* the cpu slab which is actively allocated from by the processor that
81+
* froze it and it is not on any list. The processor that froze the
8182
* slab is the one who can perform list operations on the slab. Other
8283
* processors may put objects onto the freelist but the processor that
8384
* froze the slab is the only one that can retrieve the objects from the
8485
* slab's freelist.
8586
*
87+
* CPU partial slabs
88+
*
89+
* The partially empty slabs cached on the CPU partial list are used
90+
* for performance reasons, which speeds up the allocation process.
91+
* These slabs are not frozen, but are also exempt from list management,
92+
* by clearing the PG_workingset flag when moving out of the node
93+
* partial list. Please see __slab_free() for more details.
94+
*
95+
* To sum up, the current scheme is:
96+
* - node partial slab: PG_Workingset && !frozen
97+
* - cpu partial slab: !PG_Workingset && !frozen
98+
* - cpu slab: !PG_Workingset && frozen
99+
* - full slab: !PG_Workingset && !frozen
100+
*
86101
* list_lock
87102
*
88103
* The list_lock protects the partial and full list on each node and
@@ -2617,8 +2632,7 @@ static void put_partials_cpu(struct kmem_cache *s,
26172632
}
26182633

26192634
/*
2620-
* Put a slab that was just frozen (in __slab_free|get_partial_node) into a
2621-
* partial slab slot if available.
2635+
* Put a slab into a partial slab slot if available.
26222636
*
26232637
* If we did not find a slot then simply move all the partials to the
26242638
* per node partial list.

0 commit comments

Comments
 (0)