On Tue, Dec 02, 2025 at 05:00:08PM +0800, Hao Li wrote: > Introduce barn_get_full_sheaf(), a helper that detaches a full sheaf from > the per-node barn without requiring an empty sheaf in exchange. > > Use this helper in __pcs_replace_empty_main() to change how an empty main > per-CPU sheaf is handled: > > - If pcs->spare is NULL and pcs->main is empty, first try to obtain a > full sheaf from the barn via barn_get_full_sheaf(). On success, park > the empty main sheaf in pcs->spare and install the full sheaf as the > new pcs->main. > > - If pcs->spare already exists and has objects, keep the existing > behavior of simply swapping pcs->main and pcs->spare. > > - Only when both pcs->main and pcs->spare are empty do we fall back to > barn_replace_empty_sheaf() and trade the empty main sheaf into the > barn in exchange for a full one.
Hi Hao, Yeah this is a very subtle difference between __pcs_replace_full_main() and __pcs_replace_empty_main(), that the former installs the full main sheaf in pcs->spare, while the latter replaces the empty main sheaf with a full sheaf from the barn without populating pcs->spare. Is it intentional, Vlastimil? > This makes the empty-main path more symmetric with __pcs_replace_full_main(), > which for a full main sheaf parks the full sheaf in pcs->spare and pulls an > empty sheaf from the barn. It also matches the documented design more closely: > > "When both percpu sheaves are found empty during an allocation, an empty > sheaf may be replaced with a full one from the per-node barn." I'm not convinced that this change is worthwhile by adding more code; you probably need to make a stronger argument for why it should be done. > Signed-off-by: Hao Li <[email protected]> > --- -- Cheers, Harry / Hyeonggon

