Re: [Question] Detecting Sleep-in-Atomic Context in PREEMPT_RT via RV (Runtime Verification) monitor rtapp:sleep

From: Gabriele Monaco

Date: Tue Dec 23 2025 - 10:21:22 EST


Hi Yunseong,

> I will also double-check sleepable memory allocations in the context of
> PREEMPT_RT kernels to see if there are other patterns being missed.

You may want to play with lockdep as well, it's much heavier but can catch a lot
of those issues. I believe it still relies on annotations though, so it might
have blind spots too (though it's battle-tested on locks).

> My interest in this arose because I've been seeing these legacy patterns
> consistently reported as bugs in the Real-Time (PREEMPT_RT) kernel. It
> seems many kernel developers are still unaware that these patterns are
> problematic, partly because some older Linux learning materials actually
> recommended them. This makes it quite likely that such code will continue
> to find its way into the upstream.

Yeah that's quite common indeed, I see kernel functions claiming to be atomic
while in fact using (sleeping) spinlocks.

Reading the material Daniel left (RV's original author), he thought of a similar
model, so at least we know there was interest in this kind of thing.


> I will keep looking into more meaningful contributions for RV. For instance,
> I’ve been considering a monitor to detect excessive memory compaction issues
> under specific workloads, which I’ve encountered during kernel development.

Looking forward to knowing more!

Cheers,
Gabriele