Re: [RFC] net: inet: Potential sleep in atomic context in inet_twsk_hashdance_schedule on PREEMPT_RT

From: Sebastian Andrzej Siewior
Date: Tue Aug 19 2025 - 06:09:02 EST


On 2025-08-19 01:46:10 [+0900], Yunseong Kim wrote:
> Hi everyone,
Hi,

> {
> ...
> local_bh_disable();
> spin_lock(&bhead->lock);
> spin_lock(&bhead2->lock);
> ...
> }
>
> The sequence local_bh_disable() followed by spin_lock(), In a PREEMPT_RT
> enabled kernel, spin_lock() is replaced by a mutex that an sleep.
> However, local_bh_disable() creates an atomic context by incrementing
> preempt_count, where sleeping is forbidden.

As Eric said, the mentioned pattern is common and not problematic.
The wrong assumption here is that local_bh_disable() on PREEMPT_RT
"creates an atomic context by incrementing preempt_count, where sleeping
is forbidden". This is simply not the case.

> Best regards,
> Yunseong Kim

Sebastian