From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752672AbdB1NLk (ORCPT ); Tue, 28 Feb 2017 08:11:40 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:58041 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752651AbdB1NLb (ORCPT ); Tue, 28 Feb 2017 08:11:31 -0500 Date: Tue, 28 Feb 2017 14:05:13 +0100 From: Peter Zijlstra To: Byungchul Park 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 Subject: Re: [PATCH v5 06/13] lockdep: Implement crossrelease feature Message-ID: <20170228130513.GH5680@worktop> References: <1484745459-2055-1-git-send-email-byungchul.park@lge.com> <1484745459-2055-7-git-send-email-byungchul.park@lge.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1484745459-2055-7-git-send-email-byungchul.park@lge.com> User-Agent: Mutt/1.5.22.1 (2013-10-16) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 18, 2017 at 10:17:32PM +0900, Byungchul Park wrote: > +#define MAX_XHLOCKS_NR 64UL > +#ifdef CONFIG_LOCKDEP_CROSSRELEASE > + if (tsk->xhlocks) { > + void *tmp = tsk->xhlocks; > + /* Disable crossrelease for current */ > + tsk->xhlocks = NULL; > + vfree(tmp); > + } > +#endif > +#ifdef CONFIG_LOCKDEP_CROSSRELEASE > + p->xhlock_idx = 0; > + p->xhlock_idx_soft = 0; > + p->xhlock_idx_hard = 0; > + p->xhlock_idx_nmi = 0; > + p->xhlocks = vzalloc(sizeof(struct hist_lock) * MAX_XHLOCKS_NR); I don't think we need vmalloc for this now. > + p->work_id = 0; > +#endif > +#ifdef CONFIG_LOCKDEP_CROSSRELEASE > + if (p->xhlocks) { > + void *tmp = p->xhlocks; > + /* Diable crossrelease for current */ > + p->xhlocks = NULL; > + vfree(tmp); > + } > +#endif Second instance of the same code, which would suggest using a function for this. Also, with a function you can loose the #ifdeffery.