Skip to content

Commit

Permalink
lockdep: Fix trace_hardirqs_on_caller()
Browse files Browse the repository at this point in the history
Commit dd4e5d3 ("lockdep: Fix trace_[soft,hard]irqs_[on,off]()
recursion") made a bit of a mess of the various checks and error
conditions.

In particular it moved the check for !irqs_disabled() before the
spurious enable test, resulting in some warnings.

Reported-by: Arnaud Lacombe <lacombar@gmail.com>
Reported-by: Dave Jones <davej@redhat.com>
Reported-and-tested-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1311679697.24752.28.camel@twins
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Aug 4, 2011
1 parent d7619fe commit 7d36b26
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions kernel/lockdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -2485,23 +2485,9 @@ static void __trace_hardirqs_on_caller(unsigned long ip)
{
struct task_struct *curr = current;

if (DEBUG_LOCKS_WARN_ON(unlikely(early_boot_irqs_disabled)))
return;

if (unlikely(curr->hardirqs_enabled)) {
/*
* Neither irq nor preemption are disabled here
* so this is racy by nature but losing one hit
* in a stat is not a big deal.
*/
__debug_atomic_inc(redundant_hardirqs_on);
return;
}
/* we'll do an OFF -> ON transition: */
curr->hardirqs_enabled = 1;

if (DEBUG_LOCKS_WARN_ON(current->hardirq_context))
return;
/*
* We are going to turn hardirqs on, so set the
* usage bit for all held locks:
Expand Down Expand Up @@ -2529,9 +2515,25 @@ void trace_hardirqs_on_caller(unsigned long ip)
if (unlikely(!debug_locks || current->lockdep_recursion))
return;

if (unlikely(current->hardirqs_enabled)) {
/*
* Neither irq nor preemption are disabled here
* so this is racy by nature but losing one hit
* in a stat is not a big deal.
*/
__debug_atomic_inc(redundant_hardirqs_on);
return;
}

if (DEBUG_LOCKS_WARN_ON(!irqs_disabled()))
return;

if (DEBUG_LOCKS_WARN_ON(unlikely(early_boot_irqs_disabled)))
return;

if (DEBUG_LOCKS_WARN_ON(current->hardirq_context))
return;

current->lockdep_recursion = 1;
__trace_hardirqs_on_caller(ip);
current->lockdep_recursion = 0;
Expand Down

0 comments on commit 7d36b26

Please sign in to comment.