On 2026-03-18 08:43:32 [-0700], Paul E. McKenney wrote: > > Your patch just s/spinlock_t/raw_spinlock_t so we get the locking/ > > nesting right. The wakeup problem remains, right? > > But looking at the code, there is just srcu_funnel_gp_start(). If its > > srcu_schedule_cbs_sdp() / queue_delayed_work() usage is always delayed > > then there will be always a timer and never a direct wake up of the > > worker. Wouldn't that work? > > Right, that patch fixes one lockdep problem, but another remains.
What remains? > > > It would be nice, but your point about needing to worry about spinlocks > > > is compelling. > > > > > > But couldn't lockdep scan the current task's list of held locks and see > > > whether only raw spinlocks are held (including when no spinlocks of any > > > type are held), and complain in that case? Or would that scanning be > > > too high of overhead? (But we need that scan anyway to check deadlock, > > > don't we?) > > > > PeterZ didn't like it and the nesting thing identified most of the > > problem cases. It should also catch _this_ one. > > > > Thinking about it further, you don't need to worry about > > local_bh_disable() but RCU will becomes another corner case. You would > > have to exclude "rcu_read_lock(); spin_lock();" on a !preempt kernel > > which would otherwise lead to false positives. > > But as I said, this case as explained is a nesting problem and should be > > reported by lockdep with its current features. > > With a raw spinlock held, agreed. > > Not a big deal, just working out what to put in rcutorture to avoid > regressions that would otherwise result in being unable to invoke > call_srcu() from non-preemptible contexts. Okay. So take this as _no_ more work items ;) > > > > > Thanx, Paul [2] > > > > > > > > > > [1] The exceptions to this rule being handled by the call to > > > > > invoke_rcu_core() when rcu_is_watching() returns false. > > > > > > > > > > [2] Ah, and should vanilla RCU's call_rcu() be invokable from NMI > > > > > handlers? Or should there be a call_rcu_nmi() for this purpose? > > > > > Or should we continue to have its callers check in_nmi() when > > > > > needed? > > > > > > > > Did someone ask for this? > > > > > > Yes. The BPF guys need to invoke call_srcu() from interrupts-disabled > > > regions of code. I am way to old and lazy to do this sort of thing > > > spontaneously. ;-) > > > > IRQ disabled should work but you asked about call_rcu_nmi() and NMI is > > already complicated because "most" other things don't work and you would > > need irq_work to let the remaining kernel know that you did something in > > NMI and this needs to be integrated now. I don't think regular RCU has > > call_rcu() from NMI. But I guess wrapping it via irq_work would be one > > way of dealing with it. > > Agreed, and as long as there is only a few call_rcu() call sites within > NMI handlers, it is best to let the caller deal with it. But if this > becomes popular enough, it would be better to have a call_rcu_nmi() or > some such. Popular? Okay. Keep me posted, please. > Thanx, Paul Sebastian
