Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp33178ybl; Mon, 12 Aug 2019 11:12:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqzD6BCFR40L5wRcC1NiYZUsIGY6KwvwhvClxzANLCIcIq5wMUX2x6BcsbfO3AvWJChSsYa6 X-Received: by 2002:aa7:9ab8:: with SMTP id x24mr3429856pfi.98.1565633539618; Mon, 12 Aug 2019 11:12:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565633539; cv=none; d=google.com; s=arc-20160816; b=edmVefr+4m+IiGKs4dV917pB10OledAP/dJol/ClIhQwpurplrGJxfpuDuGRrKnZh+ dwbv7lHCKm+6hfFODQgfkb+HmqWLe3Ajg25d2ZI3E9l2CjjHYKW56KzG6Id62RGOcKaP ujry/HloPE7ZcImpoFCUpqzLXH7YXmeQJufZ2yc8bG98aKC9QZCC1Kdu91tCSRTcMEbc pKYFrc8KdtUqWuopHxE4JNY+twZPyl3URPyfTnnxSxpMSK6xEx1OoD2nnTCEelUi4oUS scAtr8zAbc7r225pbetC3LUsLCXpgarrpuRKovVGI11SeDMYZrV0voSb6zX3L7B80rMY IvUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=ak3rqCpyGTUlgH5z1+mbxHIF5mH9s+NraES30HdirQs=; b=fRVmllKahU+pCM0Q31MIBMp6uw1Q9tr4Lp97UQqglkTzP5zvEdAHg2M4hI6ZbnSWXo nxgjeQPBEW0Vq+t2uSybMG251SC6n95BFmqkNHNCmWPRJE9bDnw6AS3yWNFu0svHSLwN UAYkQt8Xq0TYYv6weQGp/JrHyhrWa2cmcZyBxyC8w4gx4o44Fum0SsbI1iRseW+8I2tJ IlkLgMioTIFM6iyuUzbvr8CyZNyry27tuGc3Y3OSGVVy2N/rm9VTIkTHcb3DKHDnjkld EVtFQ0jgJnKQhwt/xtuK9v9a9mGX2diY1uNhQpsENYN+Ow1SSIe3n03+rpr0HQ7c3pXX TJvg== ARC-Authentication-Results: i=1; mx.google.com; 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 o2si22127438pgc.349.2019.08.12.11.12.03; Mon, 12 Aug 2019 11:12:19 -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; 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 S1726509AbfHLSLX (ORCPT + 99 others); Mon, 12 Aug 2019 14:11:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:57836 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726144AbfHLSLX (ORCPT ); Mon, 12 Aug 2019 14:11:23 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 284FA2067D; Mon, 12 Aug 2019 18:11:21 +0000 (UTC) Date: Mon, 12 Aug 2019 14:11:19 -0400 From: Steven Rostedt To: Joel Fernandes 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: <20190812141119.6ec00a34@gandalf.local.home> In-Reply-To: <20190812130310.GA27552@google.com> References: <20190811221111.99401-1-joel@joelfernandes.org> <20190811221111.99401-3-joel@joelfernandes.org> <20190812050256.GC5834@kroah.com> <20190812130310.GA27552@google.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. -- Steve