Re: __local_bh_enable_ip() vs lockdep

From: Peter Zijlstra
Date: Fri Dec 18 2020 - 10:46:07 EST


On Fri, Dec 18, 2020 at 04:37:16PM +0100, Peter Zijlstra wrote:
> On Fri, Dec 18, 2020 at 04:33:56PM +0100, Heiko Carstens wrote:
>
> > Peter, will you make proper patch out of this?
>
> Yes, let me go do that now, and stick it in the quilt series before I go
> off and don't think for 2 weeks.

As below, I'll try and push it out to tip/locking/urgent before I really
dissapear.

---

Subject: softirq: Avoid bad tracing / lockdep interaction
From: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Date: Fri Dec 18 16:39:14 CET 2020

Similar to commit:

1a63dcd8765b ("softirq: Reorder trace_softirqs_on to prevent lockdep splat")

__local_bh_enable_ip() can also call into tracing with inconsistent
state. Unlike that commit we don't need to bother about the tracepoint
because 'cnt-1' never matches preempt_count() (by construction).

Reported-by: Heiko Carstens <hca@xxxxxxxxxxxxx>
Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
Tested-by: Heiko Carstens <hca@xxxxxxxxxxxxx>
---
kernel/softirq.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -186,7 +186,7 @@ void __local_bh_enable_ip(unsigned long
* Keep preemption disabled until we are done with
* softirq processing:
*/
- preempt_count_sub(cnt - 1);
+ __preempt_count_sub(cnt - 1);

if (unlikely(!in_interrupt() && local_softirq_pending())) {
/*