From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933314AbcLNQF0 (ORCPT ); Wed, 14 Dec 2016 11:05:26 -0500 Received: from mail-oi0-f52.google.com ([209.85.218.52]:35349 "EHLO mail-oi0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933266AbcLNQFZ (ORCPT ); Wed, 14 Dec 2016 11:05:25 -0500 MIME-Version: 1.0 In-Reply-To: <20161214150130.GE6279@linux-x5ow.site> References: <148143770485.10950.13227732273892953675.stgit@dwillia2-desk3.amr.corp.intel.com> <148143773119.10950.13840765929901351011.stgit@dwillia2-desk3.amr.corp.intel.com> <20161214150130.GE6279@linux-x5ow.site> From: Dan Williams Date: Wed, 14 Dec 2016 07:55:31 -0800 Message-ID: Subject: Re: [PATCH 5/8] dax: refactor locking out of size calculation routines To: Johannes Thumshirn Cc: "linux-nvdimm@lists.01.org" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 14, 2016 at 7:01 AM, Johannes Thumshirn wrote: > Hi Dan, > > On Sat, Dec 10, 2016 at 10:28:51PM -0800, Dan Williams wrote: >> In preparation for other callers of these routines make the locking the >> responsibility of the caller. >> >> Signed-off-by: Dan Williams >> --- >> drivers/dax/dax.c | 30 ++++++++++++++++++++++++------ >> 1 file changed, 24 insertions(+), 6 deletions(-) >> >> diff --git a/drivers/dax/dax.c b/drivers/dax/dax.c >> index d878a56cf3e3..5b65eaff6ace 100644 >> --- a/drivers/dax/dax.c >> +++ b/drivers/dax/dax.c >> @@ -90,11 +90,11 @@ static unsigned long long dax_region_avail_size( >> unsigned long long size; >> struct resource *res; >> >> - mutex_lock(&dax_region->lock); >> + WARN_ON_ONCE(!mutex_is_locked(&dax_region->lock)); > > I'd prefer it a lockdep_assert_held(&dex_region->lock). This of cause has the > drawback that it won't trigger w/o lockdep but enabled, but I don't think it's > the responibility of a production kernel to have this warnings anyway. On the > flip side you get all the lockdep beauty for free with it. True, yes, it's only a developer debug warning. I'll change it and fix up the other pattern like this in libnvdimm.