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

locking/lockdep: Use lockdep_init_task for task initiation consistently

Despite that there is a lockdep_init_task() which does nothing, lockdep
initiates tasks by assigning lockdep fields and does so inconsistently. Fix
this by using lockdep_init_task().
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-8-duyuyang@gmail.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent d16dbd1b
...@@ -287,6 +287,8 @@ extern void lockdep_free_key_range(void *start, unsigned long size); ...@@ -287,6 +287,8 @@ extern void lockdep_free_key_range(void *start, unsigned long size);
extern asmlinkage void lockdep_sys_exit(void); extern asmlinkage void lockdep_sys_exit(void);
extern void lockdep_set_selftest_task(struct task_struct *task); extern void lockdep_set_selftest_task(struct task_struct *task);
extern void lockdep_init_task(struct task_struct *task);
extern void lockdep_off(void); extern void lockdep_off(void);
extern void lockdep_on(void); extern void lockdep_on(void);
...@@ -411,6 +413,10 @@ extern void lock_unpin_lock(struct lockdep_map *lock, struct pin_cookie); ...@@ -411,6 +413,10 @@ extern void lock_unpin_lock(struct lockdep_map *lock, struct pin_cookie);
#else /* !CONFIG_LOCKDEP */ #else /* !CONFIG_LOCKDEP */
static inline void lockdep_init_task(struct task_struct *task)
{
}
static inline void lockdep_off(void) static inline void lockdep_off(void)
{ {
} }
...@@ -503,7 +509,6 @@ enum xhlock_context_t { ...@@ -503,7 +509,6 @@ enum xhlock_context_t {
{ .name = (_name), .key = (void *)(_key), } { .name = (_name), .key = (void *)(_key), }
static inline void lockdep_invariant_state(bool force) {} static inline void lockdep_invariant_state(bool force) {}
static inline void lockdep_init_task(struct task_struct *task) {}
static inline void lockdep_free_task(struct task_struct *task) {} static inline void lockdep_free_task(struct task_struct *task) {}
#ifdef CONFIG_LOCK_STAT #ifdef CONFIG_LOCK_STAT
......
...@@ -166,6 +166,8 @@ struct task_struct init_task ...@@ -166,6 +166,8 @@ struct task_struct init_task
.softirqs_enabled = 1, .softirqs_enabled = 1,
#endif #endif
#ifdef CONFIG_LOCKDEP #ifdef CONFIG_LOCKDEP
.lockdep_depth = 0, /* no locks held yet */
.curr_chain_key = 0,
.lockdep_recursion = 0, .lockdep_recursion = 0,
#endif #endif
#ifdef CONFIG_FUNCTION_GRAPH_TRACER #ifdef CONFIG_FUNCTION_GRAPH_TRACER
......
...@@ -1984,9 +1984,6 @@ static __latent_entropy struct task_struct *copy_process( ...@@ -1984,9 +1984,6 @@ static __latent_entropy struct task_struct *copy_process(
p->pagefault_disabled = 0; p->pagefault_disabled = 0;
#ifdef CONFIG_LOCKDEP #ifdef CONFIG_LOCKDEP
p->lockdep_depth = 0; /* no locks held yet */
p->curr_chain_key = 0;
p->lockdep_recursion = 0;
lockdep_init_task(p); lockdep_init_task(p);
#endif #endif
......
...@@ -359,6 +359,13 @@ static inline u64 iterate_chain_key(u64 key, u32 idx) ...@@ -359,6 +359,13 @@ static inline u64 iterate_chain_key(u64 key, u32 idx)
return k0 | (u64)k1 << 32; return k0 | (u64)k1 << 32;
} }
void lockdep_init_task(struct task_struct *task)
{
task->lockdep_depth = 0; /* no locks held yet */
task->curr_chain_key = 0;
task->lockdep_recursion = 0;
}
void lockdep_off(void) void lockdep_off(void)
{ {
current->lockdep_recursion++; current->lockdep_recursion++;
...@@ -4589,9 +4596,7 @@ void lockdep_reset(void) ...@@ -4589,9 +4596,7 @@ void lockdep_reset(void)
int i; int i;
raw_local_irq_save(flags); raw_local_irq_save(flags);
current->curr_chain_key = 0; lockdep_init_task(current);
current->lockdep_depth = 0;
current->lockdep_recursion = 0;
memset(current->held_locks, 0, MAX_LOCK_DEPTH*sizeof(struct held_lock)); memset(current->held_locks, 0, MAX_LOCK_DEPTH*sizeof(struct held_lock));
nr_hardirq_chains = 0; nr_hardirq_chains = 0;
nr_softirq_chains = 0; nr_softirq_chains = 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