Re: [PATCH v4] lockdep: Fix wait context check on softirq for PREEMPT_RT

From: Ingo Molnar
Date: Tue Mar 25 2025 - 18:03:49 EST



* Boqun Feng <boqun.feng@xxxxxxxxx> wrote:

> On Tue, Mar 25, 2025 at 10:42:36AM +0100, Ingo Molnar wrote:
> >
> > * Boqun Feng <boqun.feng@xxxxxxxxx> wrote:
> >
> > > Since commit 0c1d7a2c2d32 ("lockdep: Remove softirq accounting on
> > > PREEMPT_RT."), the wait context test for mutex usage within
> > > "in softirq context" fails as it references @softirq_context.
> > >
> > > [ 0.184549] | wait context tests |
> > > [ 0.184549] --------------------------------------------------------------------------
> > > [ 0.184549] | rcu | raw | spin |mutex |
> > > [ 0.184549] --------------------------------------------------------------------------
> > > [ 0.184550] in hardirq context: ok | ok | ok | ok |
> > > [ 0.185083] in hardirq context (not threaded): ok | ok | ok | ok |
> > > [ 0.185606] in softirq context: ok | ok | ok |FAILED|
> > >
> > > As a fix, add lockdep map for BH disabled section. This fixes the
> > > issue by letting us catch cases when local_bh_disable() gets called
> > > with preemption disabled where local_lock doesn't get acquired.
> > > In the case of "in softirq context" selftest, local_bh_disable() was
> > > being called with preemption disable as it's early in the boot.
> > >
> > > [boqun: Move the lockdep annotations into __local_bh_*() to avoid false
> > > positives because of unpaired local_bh_disable() reported by Borislav
> > > Petkov [1] and Peter Zijlstra [2], and make bh_lock_map only exist for
> > > PREEMPT_RT]
> > >
> > > Signed-off-by: Ryo Takakura <ryotkkr98@xxxxxxxxx>
> > > Signed-off-by: Boqun Feng <boqun.feng@xxxxxxxxx>
> > > Link: https://lore.kernel.org/all/20250306122413.GBZ8mT7Z61Tmgnh5Y9@fat_crate.local/ [1]
> > > Link: https://lore.kernel.org/lkml/20250307113955.GK16878@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/ [2]
> > > Link: https://lore.kernel.org/r/20250118054900.18639-1-ryotkkr98@xxxxxxxxx
> >
> > That's a weird SOB chain. Following back the history of the submission
> > I believe this line went missing:
> >
> > From: Ryo Takakura <ryotkkr98@xxxxxxxxx>
> >
> > I added it back in to the commit.
> >
>
> Thanks! Looks like I lost the "From:" field when I post the draft of v4
> at:
>
> https://lore.kernel.org/lkml/Z8t8imzJVhWyDvhC@boqun-archlinux/
>
> I must re-apply that email as a patch to my branch, hence the "From:"
> field got changed. Sorry for the mistakes.

No worries - sometimes when rebasing with a conflict or applying with a
conflict, Git can drop authorship without much of a warning - I've ran
into that myself - so it happens.

Thanks,

Ingo