Re: [PATCH] slab: distinguish lock and trylock for sheaf_flush_main()

From: Harry Yoo

Date: Tue Mar 03 2026 - 20:06:32 EST


On Mon, Mar 02, 2026 at 10:56:44AM +0100, Vlastimil Babka (SUSE) wrote:
> On 2/26/26 15:50, Vlastimil Babka (SUSE) wrote:
> > On 2/11/26 10:42, Vlastimil Babka wrote:
> >> sheaf_flush_main() can be called from __pcs_replace_full_main() where
> >> the trylock can in theory fail, and pcs_flush_all() where it's not
> >> expected to and it would be actually a problem if it failed and left the
> >> main sheaf not flushed.
> >
> > Thinking about this more, I now think it's not a theoretical issue because
> > on PREEMPT_RT I think pcs_flush_all() can preempt someone holding the lock

Agreed!

> > (on PREEMPT_RT it doesn't have to be an irq handler preempting a holder),
> > and then fail to flush the main sheaf silently.
> >
> > The impact is probably limited though - if this failure to flush happens in
> > __kmem_cache_shutdown(), it means someone was destroying a cache while using
> > it, so that was already buggy. slab_mem_going_offline_callback() could be
> > where this matters although it's unlikely someone would do memory hotplug
> > together with PREEMPT_RT.
> >
> > But maybe still worth tagging this as Fixes: 2d517aa09bbc ("slab: add opt-in
> > caching layer of percpu sheaves") and Cc stable and sending it as a hotfix.
>
> Added to slab/for-next-fixes with adjusted changelog:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab.git/commit/?h=slab*for-next-fixes&id=48647d3f9a644d1e81af6558102d43cdb260597b

--
Cheers,
Harry / Hyeonggon