Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4715068ybl; Mon, 13 Jan 2020 19:19:01 -0800 (PST) X-Google-Smtp-Source: APXvYqwGJEZlrFHwNBaomIf6FAwgQlfrdJAdD3d9rIcdgvOpaETJosPNOS2rtNxut/P68LkKQnu2 X-Received: by 2002:a9d:6251:: with SMTP id i17mr15604239otk.14.1578971941046; Mon, 13 Jan 2020 19:19:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578971941; cv=none; d=google.com; s=arc-20160816; b=IKrLaix2XV0ZJ+1KjLhU1muOA4uX2Rx8YfXXpMFtyGiuwnaY9W9yWb0lu80NEbUdmw uJWTAP1Vl0zBlcN+FoqimQF2EWrO5MqojHril3BT/h/hn5eTWpEXi9nYc72z/9ssRayx 3WBn3118tNbFGoNvhNYQRAcFgJnlYf8JVoWGegOqGaBSEJvXQIXd6B9eyJcHb26QGQPF guFub/VR/V4qhZ4zoVPcSmkS3SZfVFpnU7gRtXVhZG5ks6nq+ouO7zAkKq5PVXT+/AXY iV2DPUblXv38YTFKm38RihXbCIuWXrpBejdbKJ3OMu76m9sutLetBQ2stkpxgFhoHp0Q tY4Q== 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=Xw77Nj8XUDXZQNK7NNDsnZyCzzV6HvnWRz+soLowYlo=; b=oxruIhCXreoqQP0TmMWLWjb+9xzWxconDYKjW/apCbdkxEuY83/377avhbZlIwtnii M327Qod6YOp8cYFwZBvyLEnFWDyanwvO9Af9aBGDef4LCakF6DLjEIly9h1K/EUg6TS3 4HODickxef5YVTOvwx+j0hb6Ui+9A9SQiGDkZg9Qhkbqz8fbDMiQriOHC0wvNBhQeNA5 saUgtQX4WyzZffyTWyj3Ow7bfOkaLL9LaNXVJf4sJDXiWe2efHVq/ZCqIQWudu6ibS2K p7OSoa2LpiB1dYPk8D9YkvhJiTjCbTeGlp3wNat9NPpoZVf/PwJmAKa5qoVcD80b7nnk z/KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VtK5kb1I; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w4si7207472otq.144.2020.01.13.19.18.49; Mon, 13 Jan 2020 19:19:01 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=VtK5kb1I; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729095AbgANDAl (ORCPT + 99 others); Mon, 13 Jan 2020 22:00:41 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:47088 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728838AbgANDAl (ORCPT ); Mon, 13 Jan 2020 22:00:41 -0500 Received: by mail-pl1-f194.google.com with SMTP id y8so4616959pll.13 for ; Mon, 13 Jan 2020 19:00:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Xw77Nj8XUDXZQNK7NNDsnZyCzzV6HvnWRz+soLowYlo=; b=VtK5kb1IIXzAZGv5xfHcXoUA1l/Ad6CPQ9LUKhr+RoI7TeYws3etYYok+4TRX4ZIJC wDmYyPNesscKL7dJTvpH9NWKzONlXQSHjS/LK+kBhzuHjODJXMK5gUAJ56lBcDYA957F rVNYNjraamPxQlGrJR/UrQuBnJERHHToi6T0q/zZuyohqY5DQn+0WLFUkYv36lzpRoVe WqBgHdLDe9964l4TI+9CM59mxiq+oCrhI6vw4sq7UvS/plJckPHwO6dr6mUVLINMp7kS 0VUkVeQSnKZo/nscboNpuZNw6tXGbRZnPEf+ulBgyjBoJuvhMj2e/nEV5FFA30Yp7JnY kHVg== 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=Xw77Nj8XUDXZQNK7NNDsnZyCzzV6HvnWRz+soLowYlo=; b=Xcx0wCJrW3y56qM3ivfQrpd2FkOaGccqicSJqfm6NPw0eP3EiFy1F2c0wa8erHUM45 oeuTgXMZuXjJmeuzcI5ZSYHYqub1FBxWljXXAJlXutMwjd6vgxvvB+ohskh6fgweVmlA mFD/kPPysEe7VtKXiwzUPPCUKXvF3DZI+eKIkTgfJX4EqYaPTfUAHjrkWnL5oj4svOtl FEfPbXcJ2fq6W1EWQpYZeHqBW64WJuaoedvYDlFw4UyMi430FGFEDk7XcJSTLXTwMQ0H 8q14EJYXBQGnLBXGU34sUa48kW1E9DVJPXK+Hg2PU654oJaYWN6Qxs6p31pCRujCgW29 23HA== X-Gm-Message-State: APjAAAX57+vY8vEb8N/MUGUbQIbRFKrKfZ17zmh4cRoJG7F0p4G/ouPo hf4Sad1tscmcN+zZnh5zN5w= X-Received: by 2002:a17:902:124:: with SMTP id 33mr17206920plb.115.1578970839903; Mon, 13 Jan 2020 19:00:39 -0800 (PST) Received: from workstation-portable ([103.211.17.159]) by smtp.gmail.com with ESMTPSA id c34sm14721134pgc.61.2020.01.13.19.00.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jan 2020 19:00:39 -0800 (PST) Date: Tue, 14 Jan 2020 08:30:30 +0530 From: Amol Grover To: kbuild test robot Cc: kbuild-all@lists.01.org, Corey Minyard , Arnd Bergmann , Greg Kroah-Hartman , openipmi-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, Joel Fernandes , Madhuparna Bhowmik , "Paul E . McKenney" Subject: Re: [PATCH v2] drivers: char: ipmi: ipmi_msghandler: Pass lockdep expression to RCU lists Message-ID: <20200114030030.GB2559@workstation-portable> References: <20200110164709.26741-1-frextrite@gmail.com> <202001121358.YVbD4V9l%lkp@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202001121358.YVbD4V9l%lkp@intel.com> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jan 12, 2020 at 01:25:58PM +0800, kbuild test robot wrote: > Hi Amol, > > Thank you for the patch! Perhaps something to improve: > > [auto build test WARNING on char-misc/char-misc-testing] > [also build test WARNING on ipmi/for-next arm-soc/for-next v5.5-rc5] > [if your patch is applied to the wrong git tree, please drop us a note to help > improve the system. BTW, we also suggest to use '--base' option to specify the > base tree in git format-patch, please see https://stackoverflow.com/a/37406982] > > url: https://github.com/0day-ci/linux/commits/Amol-Grover/drivers-char-ipmi-ipmi_msghandler-Pass-lockdep-expression-to-RCU-lists/20200111-081002 > base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git 16bb7abc4a6b9defffa294e4dc28383e62a1dbcf > config: x86_64-randconfig-a003-20200109 (attached as .config) > compiler: gcc-5 (Ubuntu 5.5.0-12ubuntu1) 5.5.0 20171010 > reproduce: > # save the attached .config to linux build tree > make ARCH=x86_64 > > If you fix the issue, kindly add following tag > Reported-by: kbuild test robot > > All warnings (new ones prefixed by >>): > > In file included from include/linux/export.h:43:0, > from include/linux/linkage.h:7, > from include/linux/kernel.h:8, > from include/linux/list.h:9, > from include/linux/module.h:12, > from drivers/char/ipmi/ipmi_msghandler.c:17: > drivers/char/ipmi/ipmi_msghandler.c: In function 'find_cmd_rcvr': > include/linux/rculist.h:53:25: warning: suggest parentheses around '&&' within '||' [-Wparentheses] > RCU_LOCKDEP_WARN(!cond && !rcu_read_lock_any_held(), \ > ^ As mentioned above, RCU_LOCKDEP_WARN macro is called from __list_check_rcu with 2 parameters 1. !cond && !rcu_read_lock_any_held() 2. The message to display incase there is a lockdep warning. However, if I pass the lockdep checking condition as: list_for_each_entry_rcu(ptr, list, head, lockdep_is_held(&some_lock) || rcu_read_lock_held()) this trickles down to __list_check_rcu and then finally to RCU_LOCKDEP_WARN as (here cond is `lockdep_is_held(&some_lock) || rcu_read_lock_held()`): RCU_LOCKDEP_WARN(!lockdep_is_held(&some_lock) || rcu_read_lock_held() && !rcu_read_lock_any_held()) which according to operator precedence (I hopefully got them right) would always evaluate to true if we are in an RCU read-side critical section (without a lock), and hence, result in a false-positive lockdep warning. This could be easily solved by putting `cond` inside brackets as it is correctly done in RCU_LOCKDEP_WARN macro but not in __list_check_rcu macro. Is that so, or did I miss something? Secondly, since there is already a condition that checks for RCU read-side critical section, the extra `rcu_read_lock_held()` we supply is sort of redundant and can be skipped right? Thanks Amol > include/linux/compiler.h:58:52: note: in definition of macro '__trace_if_var' > #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond)) > ^ > >> include/linux/rcupdate.h:263:3: note: in expansion of macro 'if' > if (debug_lockdep_rcu_enabled() && !__warned && (c)) { \ > ^ > >> include/linux/rculist.h:53:2: note: in expansion of macro 'RCU_LOCKDEP_WARN' > RCU_LOCKDEP_WARN(!cond && !rcu_read_lock_any_held(), \ > ^ > include/linux/rculist.h:371:7: note: in expansion of macro '__list_check_rcu' > for (__list_check_rcu(dummy, ## cond, 0), \ > ^ > drivers/char/ipmi/ipmi_msghandler.c:1607:2: note: in expansion of macro 'list_for_each_entry_rcu' > list_for_each_entry_rcu(rcvr, &intf->cmd_rcvrs, link, > ^ > include/linux/rculist.h:53:25: warning: suggest parentheses around '&&' within '||' [-Wparentheses] > RCU_LOCKDEP_WARN(!cond && !rcu_read_lock_any_held(), \ > ^ > include/linux/compiler.h:58:61: note: in definition of macro '__trace_if_var' > #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond)) > ^ > >> include/linux/rcupdate.h:263:3: note: in expansion of macro 'if' > if (debug_lockdep_rcu_enabled() && !__warned && (c)) { \ > ^ > >> include/linux/rculist.h:53:2: note: in expansion of macro 'RCU_LOCKDEP_WARN' > RCU_LOCKDEP_WARN(!cond && !rcu_read_lock_any_held(), \ > ^ > include/linux/rculist.h:371:7: note: in expansion of macro '__list_check_rcu' > for (__list_check_rcu(dummy, ## cond, 0), \ > ^ > drivers/char/ipmi/ipmi_msghandler.c:1607:2: note: in expansion of macro 'list_for_each_entry_rcu' > list_for_each_entry_rcu(rcvr, &intf->cmd_rcvrs, link, > ^ > include/linux/rculist.h:53:25: warning: suggest parentheses around '&&' within '||' [-Wparentheses] > RCU_LOCKDEP_WARN(!cond && !rcu_read_lock_any_held(), \ > ^ > include/linux/compiler.h:69:3: note: in definition of macro '__trace_if_value' > (cond) ? \ > ^ > include/linux/compiler.h:56:28: note: in expansion of macro '__trace_if_var' > #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) ) > ^ > >> include/linux/rcupdate.h:263:3: note: in expansion of macro 'if' > if (debug_lockdep_rcu_enabled() && !__warned && (c)) { \ > ^ > >> include/linux/rculist.h:53:2: note: in expansion of macro 'RCU_LOCKDEP_WARN' > RCU_LOCKDEP_WARN(!cond && !rcu_read_lock_any_held(), \ > ^ > include/linux/rculist.h:371:7: note: in expansion of macro '__list_check_rcu' > for (__list_check_rcu(dummy, ## cond, 0), \ > ^ > drivers/char/ipmi/ipmi_msghandler.c:1607:2: note: in expansion of macro 'list_for_each_entry_rcu' > list_for_each_entry_rcu(rcvr, &intf->cmd_rcvrs, link, > ^ > > vim +/if +263 include/linux/rcupdate.h > > 632ee200130899 Paul E. McKenney 2010-02-22 254 > f78f5b90c4ffa5 Paul E. McKenney 2015-06-18 255 /** > f78f5b90c4ffa5 Paul E. McKenney 2015-06-18 256 * RCU_LOCKDEP_WARN - emit lockdep splat if specified condition is met > f78f5b90c4ffa5 Paul E. McKenney 2015-06-18 257 * @c: condition to check > f78f5b90c4ffa5 Paul E. McKenney 2015-06-18 258 * @s: informative message > f78f5b90c4ffa5 Paul E. McKenney 2015-06-18 259 */ > f78f5b90c4ffa5 Paul E. McKenney 2015-06-18 260 #define RCU_LOCKDEP_WARN(c, s) \ > f78f5b90c4ffa5 Paul E. McKenney 2015-06-18 261 do { \ > f78f5b90c4ffa5 Paul E. McKenney 2015-06-18 262 static bool __section(.data.unlikely) __warned; \ > f78f5b90c4ffa5 Paul E. McKenney 2015-06-18 @263 if (debug_lockdep_rcu_enabled() && !__warned && (c)) { \ > f78f5b90c4ffa5 Paul E. McKenney 2015-06-18 264 __warned = true; \ > f78f5b90c4ffa5 Paul E. McKenney 2015-06-18 265 lockdep_rcu_suspicious(__FILE__, __LINE__, s); \ > f78f5b90c4ffa5 Paul E. McKenney 2015-06-18 266 } \ > f78f5b90c4ffa5 Paul E. McKenney 2015-06-18 267 } while (0) > f78f5b90c4ffa5 Paul E. McKenney 2015-06-18 268 > > :::::: The code at line 263 was first introduced by commit > :::::: f78f5b90c4ffa559e400c3919a02236101f29f3f rcu: Rename rcu_lockdep_assert() to RCU_LOCKDEP_WARN() > > :::::: TO: Paul E. McKenney > :::::: CC: Paul E. McKenney > > --- > 0-DAY kernel test infrastructure Open Source Technology Center > https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel Corporation