From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751111AbdAMEi3 (ORCPT ); Thu, 12 Jan 2017 23:38:29 -0500 Received: from LGEAMRELO13.lge.com ([156.147.23.53]:33111 "EHLO lgeamrelo13.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750960AbdAMEi2 (ORCPT ); Thu, 12 Jan 2017 23:38:28 -0500 X-Original-SENDERIP: 156.147.1.125 X-Original-MAILFROM: byungchul.park@lge.com X-Original-SENDERIP: 10.177.222.33 X-Original-MAILFROM: byungchul.park@lge.com Date: Fri, 13 Jan 2017 13:38:12 +0900 From: Byungchul Park To: peterz@infradead.org, mingo@kernel.org Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH] lockdep: Make a stack_trace instance passed to check_prev_add as an arg Message-ID: <20170113043812.GC3326@X58A-UD3R> References: <20170112161643.GB3144@twins.programming.kicks-ass.net> <1484280581-32030-1-git-send-email-byungchul.park@lge.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1484280581-32030-1-git-send-email-byungchul.park@lge.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 13, 2017 at 01:09:41PM +0900, Byungchul Park wrote: > Like this. Right? Ignore this. We need to make save_trace work in different way first. > > ----->8----- > >From c6173f29ff9bf801649f3cbeb80a914fdf1b998b Mon Sep 17 00:00:00 2001 > From: Byungchul Park > 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 > --- > 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 -> 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