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

From: Matthew Wilcox

Date: Sat Aug 29 2026 - 10:50:01 EST


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.