Re: [RFC 06/10] Reclaim memory from blocked kernel stacks

From: Peter Zijlstra

Date: Mon Aug 31 2026 - 03:15:41 EST


On Sat, Aug 29, 2026 at 03:49:22PM +0100, Matthew Wilcox wrote:
> On Sat, Aug 29, 2026 at 10:49:01AM +0200, Peter Zijlstra wrote:
> > > On PREEMPT_RT, it is necessary to skip the call to
> > > alloc_pages_nolock_noprof() from under pi_lock, since with that
> > > configuration spin_trylock can end up needing to take pi_lock. But at
> > > least on !PREEMPT_RT, there is no risk of deadlock.
> >
> > Yeah, which puts the lie to that horrific hack Alexei did. We should
> > probably teach lockdep about spin_trylock() not being safe and see the
> > house of cards crumble.
>
> Why is spin_trylock() unsafe on PREEMPT_RT? It's not intuitive since
> one can mutex_trylock() in interrupt context or under spinlock.

We should not be able to do mutex_trylock() from interrupt context.

Because then we end up with an owner that is not a task, or if we
account the interrupted task as the owner, idle that owns a sleeping
lock, which also leads to problems, such as trying to boost idle and
other such nonsense.