From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f70.google.com (mail-pg0-f70.google.com [74.125.83.70]) by kanga.kvack.org (Postfix) with ESMTP id 042796B0038 for ; Thu, 2 Mar 2017 19:17:56 -0500 (EST) Received: by mail-pg0-f70.google.com with SMTP id t184so110166586pgt.1 for ; Thu, 02 Mar 2017 16:17:55 -0800 (PST) Received: from lgeamrelo11.lge.com (LGEAMRELO11.lge.com. [156.147.23.51]) by mx.google.com with ESMTP id o21si8780013pgj.320.2017.03.02.16.17.54 for ; Thu, 02 Mar 2017 16:17:54 -0800 (PST) Date: Fri, 3 Mar 2017 09:17:37 +0900 From: Byungchul Park Subject: Re: [PATCH v5 06/13] lockdep: Implement crossrelease feature Message-ID: <20170303001737.GF28562@X58A-UD3R> References: <1484745459-2055-1-git-send-email-byungchul.park@lge.com> <1484745459-2055-7-git-send-email-byungchul.park@lge.com> <20170228134018.GK5680@worktop> <20170301054323.GE11663@X58A-UD3R> <20170301122843.GF6515@twins.programming.kicks-ass.net> <20170302134031.GG6536@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170302134031.GG6536@twins.programming.kicks-ass.net> Sender: owner-linux-mm@kvack.org List-ID: To: Peter Zijlstra Cc: mingo@kernel.org, tglx@linutronix.de, walken@google.com, boqun.feng@gmail.com, kirill@shutemov.name, linux-kernel@vger.kernel.org, linux-mm@kvack.org, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, npiggin@gmail.com, kernel-team@lge.com, Michal Hocko , Nikolay Borisov , Mel Gorman On Thu, Mar 02, 2017 at 02:40:31PM +0100, Peter Zijlstra wrote: > On Wed, Mar 01, 2017 at 01:28:43PM +0100, Peter Zijlstra wrote: > > On Wed, Mar 01, 2017 at 02:43:23PM +0900, Byungchul Park wrote: > > > > It's an optimization, but very essential and important optimization. > > Since its not for correctness, please put it in a separate patch with a > good Changelog, the below would make a good beginning of that. OK. I will do it. > Also, I feel, the source comments can be improved. > > > > in hlocks[] > > > ------------ > > > A gen_id (4) --+ > > > | previous gen_id > > > B gen_id (3) <-+ > > > C gen_id (3) > > > D gen_id (2) > > > oldest -> E gen_id (1) > > > > > > in xhlocks[] > > > ------------ > > > ^ A gen_id (4) prev_gen_id (3: B's gen id) > > > | B gen_id (3) prev_gen_id (3: C's gen id) > > > | C gen_id (3) prev_gen_id (2: D's gen id) > > > | D gen_id (2) prev_gen_id (1: E's gen id) > > > | E gen_id (1) prev_gen_id (NA) > > > > > > Let's consider the case that the gen id of xlock to commit is 3. > > > > > > In this case, it's engough to generate 'the xlock -> C'. 'the xlock -> B' > > > and 'the xlock -> A' are unnecessary since it's covered by 'C -> B' and > > > 'B -> A' which are already generated by original lockdep. > > > > > > I use the prev_gen_id to avoid adding this kind of redundant > > > dependencies. In other words, xhlock->prev_gen_id >= xlock->hlock.gen_id > > > means that the previous lock in hlocks[] is able to handle the > > > dependency on its commit stage. > diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c > index a95e5d1..7baea89 100644 > --- a/kernel/locking/lockdep.c > +++ b/kernel/locking/lockdep.c > @@ -1860,6 +1860,17 @@ check_prev_add(struct task_struct *curr, struct held_lock *prev, > } > } > > + /* > + * Is the -> redundant? > + */ > + this.class = hlock_class(prev); > + this.parent = NULL; > + ret = check_noncircular(&this, hlock_class(next), &target_entry); > + if (!ret) /* exists, redundant */ > + return 2; > + if (ret < 0) > + return print_bfs_bug(ret); > + > if (!*stack_saved) { > if (!save_trace(&trace)) > return 0; This whoud be very nice if you allow to add this code. However, prev_gen_id thingy is still useful, the code above can achieve it though. Agree? -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org