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

From: Yunseong Kim

Date: Thu Dec 11 2025 - 02:59:09 EST


Thanks you Nam, for pointing that out!

On 12/11/25 14:42, Nam Cao wrote:
Yunseong Kim <ysk@xxxxxxxxxxx> writes:
I specifically believe that RV can encompass the role of
CONFIG_DEBUG_ATOMIC_SLEEP and even go beyond it.

My reasoning is that even if a sleepable (PREEMPT_RT) spinlock is used
within an IRQ/preemption disabled section, CONFIG_DEBUG_ATOMIC_SLEEP
might not trigger a warning if scheduling does not actually occur (i.e.,
if there is no contention for that spinlock). This is because the actual
debugging check happens in __might_resched().

That's not how it works. See the description of CONFIG_DEBUG_ATOMIC_SLEEP:

"If you say Y here, various routines which may sleep will become very
noisy if they are called inside atomic sections: when a spinlock is
held, inside an rcu read side critical section, inside preempt disabled
sections, inside an interrupt, etc..."

I am currently considering how to model this to cover cases that go beyond what CONFIG_DEBUG_ATOMIC_SLEEP covers.

My specific concern is about custom functions where might_sleep() might be missing. In such cases, if the code hits a fast path (no scheduling),
CONFIG_DEBUG_ATOMIC_SLEEP won't trigger. I'm wondering if RV can detect
these potential bugs.

Nam


Thanks a lot for the quick reply!

Best regards,
Yunseong Kim