Skip to content

Commit dd4e5d3

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
lockdep: Fix trace_[soft,hard]irqs_[on,off]() recursion
Commit: 1efc5da: [PATCH] order of lockdep off/on in vprintk() should be changed explains the reason for having raw_local_irq_*() and lockdep_off() in printk(). Instead of working around the broken recursion detection of interrupt state tracking, fix it. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: efault@gmx.de Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Andrew Morton <akpm@linux-foundation.org> Link: http://lkml.kernel.org/r/20110621153806.185242734@chello.nl Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent 4f2a8d3 commit dd4e5d3

1 file changed

Lines changed: 20 additions & 10 deletions

File tree

‎kernel/lockdep.c‎

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2478,15 +2478,10 @@ mark_held_locks(struct task_struct *curr, enum mark_type mark)
24782478
/*
24792479
* Hardirqs will be enabled:
24802480
*/
2481-
void trace_hardirqs_on_caller(unsigned long ip)
2481+
static void __trace_hardirqs_on_caller(unsigned long ip)
24822482
{
24832483
struct task_struct *curr = current;
24842484

2485-
time_hardirqs_on(CALLER_ADDR0, ip);
2486-
2487-
if (unlikely(!debug_locks || current->lockdep_recursion))
2488-
return;
2489-
24902485
if (DEBUG_LOCKS_WARN_ON(unlikely(early_boot_irqs_disabled)))
24912486
return;
24922487

@@ -2502,8 +2497,6 @@ void trace_hardirqs_on_caller(unsigned long ip)
25022497
/* we'll do an OFF -> ON transition: */
25032498
curr->hardirqs_enabled = 1;
25042499

2505-
if (DEBUG_LOCKS_WARN_ON(!irqs_disabled()))
2506-
return;
25072500
if (DEBUG_LOCKS_WARN_ON(current->hardirq_context))
25082501
return;
25092502
/*
@@ -2525,6 +2518,21 @@ void trace_hardirqs_on_caller(unsigned long ip)
25252518
curr->hardirq_enable_event = ++curr->irq_events;
25262519
debug_atomic_inc(hardirqs_on_events);
25272520
}
2521+
2522+
void trace_hardirqs_on_caller(unsigned long ip)
2523+
{
2524+
time_hardirqs_on(CALLER_ADDR0, ip);
2525+
2526+
if (unlikely(!debug_locks || current->lockdep_recursion))
2527+
return;
2528+
2529+
if (DEBUG_LOCKS_WARN_ON(!irqs_disabled()))
2530+
return;
2531+
2532+
current->lockdep_recursion = 1;
2533+
__trace_hardirqs_on_caller(ip);
2534+
current->lockdep_recursion = 0;
2535+
}
25282536
EXPORT_SYMBOL(trace_hardirqs_on_caller);
25292537

25302538
void trace_hardirqs_on(void)
@@ -2574,7 +2582,7 @@ void trace_softirqs_on(unsigned long ip)
25742582
{
25752583
struct task_struct *curr = current;
25762584

2577-
if (unlikely(!debug_locks))
2585+
if (unlikely(!debug_locks || current->lockdep_recursion))
25782586
return;
25792587

25802588
if (DEBUG_LOCKS_WARN_ON(!irqs_disabled()))
@@ -2585,6 +2593,7 @@ void trace_softirqs_on(unsigned long ip)
25852593
return;
25862594
}
25872595

2596+
current->lockdep_recursion = 1;
25882597
/*
25892598
* We'll do an OFF -> ON transition:
25902599
*/
@@ -2599,6 +2608,7 @@ void trace_softirqs_on(unsigned long ip)
25992608
*/
26002609
if (curr->hardirqs_enabled)
26012610
mark_held_locks(curr, SOFTIRQ);
2611+
current->lockdep_recursion = 0;
26022612
}
26032613

26042614
/*
@@ -2608,7 +2618,7 @@ void trace_softirqs_off(unsigned long ip)
26082618
{
26092619
struct task_struct *curr = current;
26102620

2611-
if (unlikely(!debug_locks))
2621+
if (unlikely(!debug_locks || current->lockdep_recursion))
26122622
return;
26132623

26142624
if (DEBUG_LOCKS_WARN_ON(!irqs_disabled()))

0 commit comments

Comments
 (0)