Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp130697ybl; Mon, 12 Aug 2019 13:04:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqxV8qHIknPxVlrrAX6u+tMj10pEO486GM+gBXQmxJorKu457wnjAYzwNhdlS8zOlNtUo87k X-Received: by 2002:a63:ee08:: with SMTP id e8mr32080622pgi.70.1565640254010; Mon, 12 Aug 2019 13:04:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565640254; cv=none; d=google.com; s=arc-20160816; b=QwEh255jfAT1DYd0wox+FAU5q1+ULXoDp/mP4Xqt9VslnqwbgOd9Ul+VlWHqnvggVk ILhH743hrM4mTkulufWHShCoGoQ8WUI7Hg3cOd+W9IOaczFyfKmc0p5jEd65spKWFIcl 4PcfI4OghYyC1HgY/EnBLH8eb//l5OXt5FX5j+V+aR+CaO3ilssYsj4z/JpOvJoR1e93 WUYqY/QwvJjPeG0ILgRsG2ee00AwQEaVa7/mymVBFxFxmuFhl7fEztvb33VYxFUsTa+d rVCBE5mJDicwwjt2dCPIGN9mCkDvPKcEs0XCGO6qGnhVyePXrr8oUXluXAy8mrMCj1dQ CygQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=t5IMBiad94ViMSwq7y4bsRJRQefPxt/6jC7yShC1dso=; b=DLpXiIuRP1k3Ui+6I4yBQeeoU8yvjL7nxKSfi+rIhNE56Ky7AXi881FhI8fH4fFD2m 9vXh8mXOIogIiFu/xjQRH/nQjFbskuLIfUNGPWE6GZSG5zUDj5v+J3DJYXXDEfjIzujK iHUVzoo0JNuBx73ZorWwbr7wx5rfmDO+5SD57l2/Z6NKfRHQd5jIhnUiVDlXiiRrgHDx 0+8yb0QYLM+T7xrbTn1WehCSEKQVxpBnBCB/ZaW8gvkImN9T8Dw7teyB9Vj01hzTbg0i QfFaP4NRnzPDrmaYxi/Eot9PbP66V/+PmhMYi4C0iWurWZlOCWKSoz46f3b9c1Fp+UZw 223A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=n8o7s9dE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t135si63119753pfc.251.2019.08.12.13.03.56; Mon, 12 Aug 2019 13:04:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=n8o7s9dE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727124AbfHLUB3 (ORCPT + 99 others); Mon, 12 Aug 2019 16:01:29 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:46599 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726910AbfHLUB2 (ORCPT ); Mon, 12 Aug 2019 16:01:28 -0400 Received: by mail-pf1-f194.google.com with SMTP id q139so1944495pfc.13 for ; Mon, 12 Aug 2019 13:01:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=t5IMBiad94ViMSwq7y4bsRJRQefPxt/6jC7yShC1dso=; b=n8o7s9dEw4INP/Gexmh1KfkKcSDs1JDp64GxVvJ20IPEbhyNxIy6CFH4ehNjOnTIZa 0Bik+2eI1LoVNTuMoZM4V9FWFce0O+s4zKl11UbxQqloUMKdLQlmcgEasc7M5tKKOUnn 7yGao+KtB6s+BKLS8Jjqhq2YfQ9JaqCZxQXBY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=t5IMBiad94ViMSwq7y4bsRJRQefPxt/6jC7yShC1dso=; b=gFPIIAllxBRIyAXFGrAKZwDVtXfkXBw4ni0BN1Re+/WNNAm66OIEHVAdt+/R1E4fuD bnHumNOZ3BPcDYh5KGtm1pMezIr827RjX1sC8Fm+7b0pcNGeqCiDt6qzbwAlVjp3XLoz zq/fScq03HnI7DOhZlvoFy4dcM6QUOVTFQUuwElq55uZhWFLNB9QQO1OYTSPn+exbpsd DE/VT6JOgYwdFXrJoNY0SeK+7QHqRDopmWDtgvqOJRM45iz1iJHJkYr3n71MGgEdwooa WLzY5r8l0ChKk5cH77obkawUSpAs4EM4cmRU+J5uupazIp/CgoICx7fxDtBh0F0HTH3N JVVg== X-Gm-Message-State: APjAAAVi0w9m5YxZZ01DYosbrWczu/Hy2xfets96oRCPVQNLuavakUPf YiOUS4SbsIJkpEfG85pdw6H3Fw== X-Received: by 2002:a62:198d:: with SMTP id 135mr36932026pfz.169.1565640088004; Mon, 12 Aug 2019 13:01:28 -0700 (PDT) Received: from localhost ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id br18sm407214pjb.20.2019.08.12.13.01.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 12 Aug 2019 13:01:27 -0700 (PDT) Date: Mon, 12 Aug 2019 16:01:25 -0400 From: Joel Fernandes To: Steven Rostedt Cc: Greg Kroah-Hartman , linux-kernel@vger.kernel.org, kbuild test robot , Jonathan Corbet , Josh Triplett , Lai Jiangshan , linux-doc@vger.kernel.org, Mathieu Desnoyers , "Paul E. McKenney" , "Rafael J. Wysocki" , rcu@vger.kernel.org, Tejun Heo Subject: Re: [PATCH 3/3] driver/core: Fix build error when SRCU and lockdep disabled Message-ID: <20190812200125.GA161786@google.com> References: <20190811221111.99401-1-joel@joelfernandes.org> <20190811221111.99401-3-joel@joelfernandes.org> <20190812050256.GC5834@kroah.com> <20190812130310.GA27552@google.com> <20190812141119.6ec00a34@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190812141119.6ec00a34@gandalf.local.home> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 12, 2019 at 02:11:19PM -0400, Steven Rostedt wrote: > On Mon, 12 Aug 2019 09:03:10 -0400 > Joel Fernandes wrote: > > > > > > drivers/base/core.c | 6 +++++- > > > > 1 file changed, 5 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/drivers/base/core.c b/drivers/base/core.c > > > > index 32cf83d1c744..fe25cf690562 100644 > > > > --- a/drivers/base/core.c > > > > +++ b/drivers/base/core.c > > > > @@ -99,7 +99,11 @@ void device_links_read_unlock(int not_used) > > > > > > > > int device_links_read_lock_held(void) > > > > { > > > > - return lock_is_held(&device_links_lock); > > > > +#ifdef CONFIG_DEBUG_LOCK_ALLOC > > > > + return lock_is_held(&(device_links_lock.dep_map)); > > > > +#else > > > > + return 1; > > > > +#endif > > > > > > return 1? So the lock is always held? > > I was thinking the exact same thing. > > > > > This is just the pattern of an assert that is disabled, so that > > false-positives don't happen if lockdep is disabled. > > > > So say someone writes a statement like: > > WARN_ON_ONCE(!device_links_read_lock_held()); > > > > Since lockdep is disabled, we cannot check whether lock is held or not. Yet, > > we don't want false positives by reporting that the lock is not held. In this > > case, it is better to report that the lock is held to suppress > > false-positives. srcu_read_lock_held() also follows the same pattern. > > > > The real answer here is to make that WARN_ON_ONCE() dependent on > lockdep. Something like: > > > some/header/file.h: > > #ifdef CONFIG_DEBUG_LOCK_ALLOC > # define CHECK_DEVICE_LINKS_READ_LOCK_HELD() WARN_ON_ONCE(!defice_links_read_lock_held()) > #else > # define CHECK_DEVICE_LINKS_READ_LOCK_HELD() do { } while (0) > #endif > > And just use CHECK_DEVICE_LINK_READ_LOCK_HELD() in those places. I > agree with Greg. "device_links_read_lock_heald()" should *never* > blindly return 1. It's confusing. Ok, then I will update the patch to do: #ifdef CONFIG_DEBUG_LOCK_ALLOC int device_links_read_lock_held(void) { return lock_is_held(&device_links_lock); } #endif That will also solve the build error. And callers can follow the above pattern you shared. thanks, - Joel