Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

slub: keep empty main sheaf as spare in __pcs_replace_empty_main()

When __pcs_replace_empty_main() fails to obtain a full sheaf directly
from the barn, it may either:

- Refill an empty sheaf obtained via barn_get_empty_sheaf(), or
- Allocate a brand new full sheaf via alloc_full_sheaf().

After reacquiring the per-CPU lock, if pcs->main is still empty and
pcs->spare is NULL, the current code donates the empty main sheaf to
the barn via barn_put_empty_sheaf() and installs the full sheaf as
pcs->main, leaving pcs->spare unpopulated.

Instead, keep the existing empty main sheaf locally as the spare:

pcs->spare = pcs->main;
pcs->main = full;

This populates pcs->spare earlier, which can reduce future barn traffic.

Suggested-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Hao Li <haolee.swjtu@gmail.com>
Reviewed-by: Harry Yoo <harry.yoo@oracle.com>
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Tested-by: Zhao Liu <zhao1.liu@intel.com>

authored by

Hao Li and committed by
Vlastimil Babka
4b038a96 d907bf43

+4 -1
+4 -1
mm/slub.c
··· 5049 5049 */ 5050 5050 5051 5051 if (pcs->main->size == 0) { 5052 - barn_put_empty_sheaf(barn, pcs->main); 5052 + if (!pcs->spare) 5053 + pcs->spare = pcs->main; 5054 + else 5055 + barn_put_empty_sheaf(barn, pcs->main); 5053 5056 pcs->main = full; 5054 5057 return pcs; 5055 5058 }