From: Liam R. Howlett Date: Fri, 17 Jan 2025 20:11:31 +0000 (-0500) Subject: mm/slub: Avoid waiting on empty per-cpu sheaf replacement X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=659871c18aaf52233dc68eebd088fb6dd3ad9d91;p=users%2Fjedix%2Flinux-maple.git mm/slub: Avoid waiting on empty per-cpu sheaf replacement When the per-cpu sheaf is empty, attempt to replace it with a full one from the barn. If the barn lock is contended then fail quickly and enter the recovery code that will refill the empty sheaf. This is to avoid congestion on the barn in the event of many tasks requesting allocations at the same time. Discovered by brk1_processes() regression from will-it-scale benchmarks. Signed-off-by: Liam R. Howlett --- diff --git a/mm/slub.c b/mm/slub.c index 1907a21c232a..5d09c3a32fb6 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2855,7 +2855,8 @@ barn_replace_empty_sheaf(struct node_barn *barn, struct slab_sheaf *empty) struct slab_sheaf *full = NULL; unsigned long flags; - spin_lock_irqsave(&barn->lock, flags); + if (!spin_trylock_irqsave(&barn->lock, flags)) + return NULL; if (barn->nr_full) { full = list_first_entry(&barn->sheaves_full, struct slab_sheaf,