Messages in this thread Patch in this message | | | From | Byungchul Park <> | Subject | [PATCH] lockdep: Make a stack_trace instance passed to check_prev_add as an arg | Date | Fri, 13 Jan 2017 13:09:41 +0900 |
| |
Like this. Right?
----->8----- From c6173f29ff9bf801649f3cbeb80a914fdf1b998b Mon Sep 17 00:00:00 2001 From: Byungchul Park <byungchul.park@lge.com> Date: Fri, 13 Jan 2017 12:02:02 +0900 Subject: [PATCH] lockdep: Make a stack_trace instance passed to check_prev_add as an arg
Saving stack_trace within check_prev_add needs many tricky codes. To avoid these, this patch makes the stack_trace instance created out of check_prev_add, but by caller and passed as an argument.
Signed-off-by: Byungchul Park <byungchul.park@lge.com> --- kernel/locking/lockdep.c | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-)
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 2081c31..049fc71 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -1797,20 +1797,13 @@ static inline void inc_chains(void) */ static int check_prev_add(struct task_struct *curr, struct held_lock *prev, - struct held_lock *next, int distance, int *stack_saved) + struct held_lock *next, int distance, + struct stack_trace *trace) { struct lock_list *entry; int ret; struct lock_list this; struct lock_list *uninitialized_var(target_entry); - /* - * Static variable, serialized by the graph_lock(). - * - * We use this static variable to save the stack trace in case - * we call into this function multiple times due to encountering - * trylocks in the held lock stack. - */ - static struct stack_trace trace; /* * Prove that the new <prev> -> <next> dependency would not @@ -1858,26 +1851,20 @@ static inline void inc_chains(void) } } - if (!*stack_saved) { - if (!save_trace(&trace)) - return 0; - *stack_saved = 1; - } - /* * Ok, all validations passed, add the new lock * to the previous lock's dependency list: */ ret = add_lock_to_list(hlock_class(prev), hlock_class(next), &hlock_class(prev)->locks_after, - next->acquire_ip, distance, &trace); + next->acquire_ip, distance, trace); if (!ret) return 0; ret = add_lock_to_list(hlock_class(next), hlock_class(prev), &hlock_class(next)->locks_before, - next->acquire_ip, distance, &trace); + next->acquire_ip, distance, trace); if (!ret) return 0; @@ -1885,8 +1872,6 @@ static inline void inc_chains(void) * Debugging printouts: */ if (verbose(hlock_class(prev)) || verbose(hlock_class(next))) { - /* We drop graph lock, so another thread can overwrite trace. */ - *stack_saved = 0; graph_unlock(); printk("\n new dependency: "); print_lock_name(hlock_class(prev)); @@ -1909,8 +1894,8 @@ static inline void inc_chains(void) check_prevs_add(struct task_struct *curr, struct held_lock *next) { int depth = curr->lockdep_depth; - int stack_saved = 0; struct held_lock *hlock; + struct stack_trace trace; /* * Debugging checks. @@ -1927,6 +1912,9 @@ static inline void inc_chains(void) curr->held_locks[depth-1].irq_context) goto out_bug; + if (!save_trace(&trace)) + return 0; + for (;;) { int distance = curr->lockdep_depth - depth + 1; hlock = curr->held_locks + depth - 1; @@ -1936,7 +1924,7 @@ static inline void inc_chains(void) */ if (hlock->read != 2 && hlock->check) { if (!check_prev_add(curr, hlock, next, - distance, &stack_saved)) + distance, &trace)) return 0; /* * Stop after the first non-trylock entry, -- 1.9.1
| |