Commit 0fc52de
mm/slub: detach and reattach partial slabs in batch
get_partial_node_bulk() moves each selected slab from the node's
partial list to the local pc->slabs list using a remove_partial() and
list_add() pair. In practice, the loop often detaches several adjacent
slabs. Doing this individually repeatedly manipulates list pointers
while holding n->list_lock, which causes unnecessary churn.
To demonstrate this, the counts below show how often single vs. multiple
consecutive slabs are retrieved during a will-it-scale mmap stress test:
consecutive_slabs_count frequency
= 1 277345324
= 2 335238023
= 3 175717884
>= 4 88862337
The data confirms that retrieving multiple contiguous slabs is highly
frequent.
To optimize this, track contiguous runs of matching slabs and move each
run in a single operation using list_bulk_move_tail(). This reduces list
pointer churn inside the lock critical section.
Apply the same optimization to __refill_objects_node() when reattaching
leftover partial slabs back to the node's partial list.
The will-it-scale mmap benchmark shows a 2% ~ 5% performance improvement
after applying this patch.
Signed-off-by: Hao Li <hao.li@linux.dev>
Link: https://patch.msgid.link/20260529035120.81304-3-hao.li@linux.dev
Reviewed-by: Harry Yoo (Oracle) <harry@kernel.org>
Signed-off-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>1 parent 7e23073 commit 0fc52de
1 file changed
Lines changed: 20 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3751 | 3751 | | |
3752 | 3752 | | |
3753 | 3753 | | |
| 3754 | + | |
3754 | 3755 | | |
3755 | 3756 | | |
3756 | 3757 | | |
| |||
3769 | 3770 | | |
3770 | 3771 | | |
3771 | 3772 | | |
3772 | | - | |
| 3773 | + | |
| 3774 | + | |
| 3775 | + | |
| 3776 | + | |
| 3777 | + | |
| 3778 | + | |
| 3779 | + | |
3773 | 3780 | | |
| 3781 | + | |
3774 | 3782 | | |
3775 | 3783 | | |
3776 | 3784 | | |
| |||
3787 | 3795 | | |
3788 | 3796 | | |
3789 | 3797 | | |
3790 | | - | |
3791 | | - | |
3792 | | - | |
| 3798 | + | |
| 3799 | + | |
| 3800 | + | |
| 3801 | + | |
3793 | 3802 | | |
3794 | 3803 | | |
3795 | 3804 | | |
3796 | 3805 | | |
3797 | 3806 | | |
3798 | 3807 | | |
| 3808 | + | |
| 3809 | + | |
| 3810 | + | |
| 3811 | + | |
3799 | 3812 | | |
3800 | 3813 | | |
3801 | 3814 | | |
| |||
7205 | 7218 | | |
7206 | 7219 | | |
7207 | 7220 | | |
7208 | | - | |
| 7221 | + | |
| 7222 | + | |
7209 | 7223 | | |
7210 | | - | |
7211 | | - | |
7212 | | - | |
| 7224 | + | |
7213 | 7225 | | |
7214 | 7226 | | |
7215 | 7227 | | |
| |||
0 commit comments