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

From: Dan Carpenter

Date: Fri Dec 12 2025 - 02:02:31 EST


On Tue, Dec 02, 2025 at 12:26:44PM +0100, Sebastian Andrzej Siewior wrote:
> On 2025-12-02 12:14:09 [+0100], Nam Cao wrote:
> > > RV is not a static checker, it is a run-time checker.
> > >
> > > Just in case you are not aware yet, there is also Smatch:
> > > https://github.com/error27/smatch. But I can't offer much help there.
> >
> > I was looking up something unrelated, and I found that Smatch does
> > detect this sleep-in-atomic problem:
> > https://staticthinking.wordpress.com/2024/05/24/sleeping-in-atomic-warnings/
> >
> > I'm not sure if its design takes PREEMPT_RT into consideration. But
> > seems worth having a look.
>
> It does not look like it does. Judging from
> https://github.com/error27/smatch/blob/master/check_preempt_info.c
>
> it increments the preempt-counter on preempt_disable() and spin_lock().
> So it won't yell at
> preempt_disable();
> spin_lock();
>
> while CONFIG_DEBUG_ATOMIC_SLEEP would.

Yeah. Sorry, I haven't updated this check for PREEMPT_RT.

There is a bug to do with cleanup.h that affects it as well. If you
have a goto from inside a scoped guard that isn't handled correctly.
I need to fix that as well.

regards,
dan carpenter