Commit 09180651 authored by Yuyang Du's avatar Yuyang Du Committed by Ingo Molnar

locking/lockdep: Consolidate lock usage bit initialization

Lock usage bit initialization is consolidated into one function
mark_usage(). Trivial readability improvement. No functional change.
Signed-off-by: default avatarYuyang Du <duyuyang@gmail.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: bvanassche@acm.org
Cc: frederic@kernel.org
Cc: ming.lei@redhat.com
Cc: will.deacon@arm.com
Link: https://lkml.kernel.org/r/20190506081939.74287-22-duyuyang@gmail.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 68e9dc29
...@@ -3460,8 +3460,12 @@ void trace_softirqs_off(unsigned long ip) ...@@ -3460,8 +3460,12 @@ void trace_softirqs_off(unsigned long ip)
debug_atomic_inc(redundant_softirqs_off); debug_atomic_inc(redundant_softirqs_off);
} }
static int mark_irqflags(struct task_struct *curr, struct held_lock *hlock) static int
mark_usage(struct task_struct *curr, struct held_lock *hlock, int check)
{ {
if (!check)
goto lock_used;
/* /*
* If non-trylock use in a hardirq or softirq context, then * If non-trylock use in a hardirq or softirq context, then
* mark the lock as used in these contexts: * mark the lock as used in these contexts:
...@@ -3505,6 +3509,11 @@ static int mark_irqflags(struct task_struct *curr, struct held_lock *hlock) ...@@ -3505,6 +3509,11 @@ static int mark_irqflags(struct task_struct *curr, struct held_lock *hlock)
} }
} }
lock_used:
/* mark it as used: */
if (!mark_lock(curr, hlock, LOCK_USED))
return 0;
return 1; return 1;
} }
...@@ -3546,8 +3555,8 @@ int mark_lock_irq(struct task_struct *curr, struct held_lock *this, ...@@ -3546,8 +3555,8 @@ int mark_lock_irq(struct task_struct *curr, struct held_lock *this,
return 1; return 1;
} }
static inline int mark_irqflags(struct task_struct *curr, static inline int
struct held_lock *hlock) mark_usage(struct task_struct *curr, struct held_lock *hlock, int check)
{ {
return 1; return 1;
} }
...@@ -3833,11 +3842,8 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass, ...@@ -3833,11 +3842,8 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
#endif #endif
hlock->pin_count = pin_count; hlock->pin_count = pin_count;
if (check && !mark_irqflags(curr, hlock)) /* Initialize the lock usage bit */
return 0; if (!mark_usage(curr, hlock, check))
/* mark it as used: */
if (!mark_lock(curr, hlock, LOCK_USED))
return 0; return 0;
/* /*
......
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