Commit c2469756 authored by Boqun Feng's avatar Boqun Feng Committed by Ingo Molnar

locking/lockdep: Fix ->irq_context calculation

task_irq_context() returns the encoded irq_context of the task, the
return value is encoded in the same as ->irq_context of held_lock.

Always return 0 if !(CONFIG_TRACE_IRQFLAGS && CONFIG_PROVE_LOCKING)
Signed-off-by: default avatarBoqun Feng <boqun.feng@gmail.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Josh Triplett <josh@joshtriplett.org>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: sasha.levin@oracle.com
Link: http://lkml.kernel.org/r/1455602265-16490-2-git-send-email-boqun.feng@gmail.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent fba7cd68
...@@ -2932,6 +2932,11 @@ static int mark_irqflags(struct task_struct *curr, struct held_lock *hlock) ...@@ -2932,6 +2932,11 @@ static int mark_irqflags(struct task_struct *curr, struct held_lock *hlock)
return 1; return 1;
} }
static inline unsigned int task_irq_context(struct task_struct *task)
{
return 2 * !!task->hardirq_context + !!task->softirq_context;
}
static int separate_irq_context(struct task_struct *curr, static int separate_irq_context(struct task_struct *curr,
struct held_lock *hlock) struct held_lock *hlock)
{ {
...@@ -2940,8 +2945,6 @@ static int separate_irq_context(struct task_struct *curr, ...@@ -2940,8 +2945,6 @@ static int separate_irq_context(struct task_struct *curr,
/* /*
* Keep track of points where we cross into an interrupt context: * Keep track of points where we cross into an interrupt context:
*/ */
hlock->irq_context = 2*(curr->hardirq_context ? 1 : 0) +
curr->softirq_context;
if (depth) { if (depth) {
struct held_lock *prev_hlock; struct held_lock *prev_hlock;
...@@ -2973,6 +2976,11 @@ static inline int mark_irqflags(struct task_struct *curr, ...@@ -2973,6 +2976,11 @@ static inline int mark_irqflags(struct task_struct *curr,
return 1; return 1;
} }
static inline unsigned int task_irq_context(struct task_struct *task)
{
return 0;
}
static inline int separate_irq_context(struct task_struct *curr, static inline int separate_irq_context(struct task_struct *curr,
struct held_lock *hlock) struct held_lock *hlock)
{ {
...@@ -3241,6 +3249,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass, ...@@ -3241,6 +3249,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
hlock->acquire_ip = ip; hlock->acquire_ip = ip;
hlock->instance = lock; hlock->instance = lock;
hlock->nest_lock = nest_lock; hlock->nest_lock = nest_lock;
hlock->irq_context = task_irq_context(curr);
hlock->trylock = trylock; hlock->trylock = trylock;
hlock->read = read; hlock->read = read;
hlock->check = check; hlock->check = check;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment