Linux Trace Kernel
 help / color / mirror / Atom feed
From: Wen Yang <wen.yang@linux.dev>
To: "Nam Cao" <namcao@linutronix.de>,
	"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>,
	"Gabriele Monaco" <gmonaco@redhat.com>
Cc: linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] rv/reactors: fix lockdep "Invalid wait context" in rv_react()
Date: Wed, 15 Jul 2026 01:39:19 +0800	[thread overview]
Message-ID: <39e4acbc-3e1b-412e-b6b8-c93f4e2c62ed@linux.dev> (raw)
In-Reply-To: <87y0fkdojp.fsf@yellow.woof>



On 7/10/26 02:07, Nam Cao wrote:
> Wen Yang <wen.yang@linux.dev> writes:
>> How about a context-sensitive approach, eg:
>>
>>     NMI/hardirq (interrupts masked, scheduler cannot run):
>>       Keep LD_WAIT_FREE.  The false positive cannot arise in this path,
>>       and the original constraint against raw spinlocks is preserved where
>>       it is meaningful.
>>
>>     task/softirq/PREEMPT_RT irq thread (preemptible):
>>       Raise to LD_WAIT_SPIN.  Raw spinlocks become permitted — as Gabriele
>>       note, this is a necessary consequence of any fix in this path.
> 
> I don't get the point. Unless the lock's type is also context-sensitive,
> the reactors still cannot use raw spin locks.
> 

Correct, and that is intentional. The patch is not about enabling raw
spinlocks in callbacks; it is about fixing a false positive in 
preemptible context while preserving LD_WAIT_FREE where it is still 
meaningful.

The lockdep check (kernel/locking/lockdep.c:4901) is:

     if (next_outer > curr_inner)  /* BUG: Invalid wait context */

The false positive in preemptible context:

     rv_react_map (inner = LD_WAIT_FREE = 1)  -->  held by override map
     timer interrupt
       __schedule
          rq->__lock (outer = LD_WAIT_SPIN = 2)
             2 > 1   --->  BUG (while callback itself took no spinlock)

In NMI/hardirq context interrupts are masked; __schedule cannot run, so
rq->__lock is never acquired in this path.  The false positive cannot
arise there, and LD_WAIT_FREE keeps raw spinlocks forbidden:

     raw_spinlock_t (outer = LD_WAIT_SPIN = 2)
     rv_react_map_atomic (inner = LD_WAIT_FREE = 1)
     2 > 1  →  BUG   (intended: hardirq callbacks must be lock-free)


The commit message's "raw spinlocks in callbacks are permitted as a
necessary consequence" is imprecise -- that applies to the preemptible
path only.  I will correct it in v2.


--
Best wishes,
Wen





  reply	other threads:[~2026-07-14 17:40 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-15 16:44 [PATCH 0/3] rv/reactors: fix lockdep warning and add KUnit tests wen.yang
2026-06-15 16:44 ` [PATCH 1/3] rv/reactors: fix lockdep "Invalid wait context" in rv_react() wen.yang
2026-06-17 11:12   ` Nam Cao
2026-06-17 15:58   ` Nam Cao
2026-06-23  9:38   ` Thomas Weißschuh
2026-07-06 14:02     ` Gabriele Monaco
2026-07-08 15:47       ` Thomas Weißschuh
2026-07-09 16:37         ` Wen Yang
2026-07-09 18:07           ` Nam Cao
2026-07-14 17:39             ` Wen Yang [this message]
2026-06-15 16:44 ` [PATCH 2/3] rv/reactors: add KUnit tests for reactor_printk wen.yang
2026-06-23  9:54   ` Thomas Weißschuh
2026-07-06 14:41   ` Gabriele Monaco
2026-07-09 16:53     ` Wen Yang
2026-06-15 16:44 ` [PATCH 3/3] rv/reactors: add KUnit tests for reactor_panic wen.yang
2026-06-20 23:30   ` XIAO WU
2026-06-21  3:34     ` Wen Yang
2026-07-06 14:48   ` Gabriele Monaco
2026-07-06 15:00   ` Gabriele Monaco
2026-07-09 16:46     ` Wen Yang
2026-07-10  8:27       ` Gabriele Monaco
2026-06-17 15:41 ` [PATCH 0/3] rv/reactors: fix lockdep warning and add KUnit tests Gabriele Monaco
2026-06-17 15:52   ` Nam Cao
2026-06-17 16:14     ` Gabriele Monaco
2026-06-17 17:11   ` Wen Yang
2026-06-18 15:35     ` Gabriele Monaco
2026-06-20  9:13       ` Wen Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=39e4acbc-3e1b-412e-b6b8-c93f4e2c62ed@linux.dev \
    --to=wen.yang@linux.dev \
    --cc=gmonaco@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=namcao@linutronix.de \
    --cc=thomas.weissschuh@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox