Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp4396753ybf; Wed, 4 Mar 2020 03:09:42 -0800 (PST) X-Google-Smtp-Source: ADFU+vtalZqBTfo2JvxYukzBqa38RZXqEQghSGRt7lJh4xpBvNHdXTiJfYHTHaL+CsdudPnNt3mY X-Received: by 2002:a05:6808:b13:: with SMTP id s19mr1281035oij.119.1583320182418; Wed, 04 Mar 2020 03:09:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583320182; cv=none; d=google.com; s=arc-20160816; b=s1blhJv7MLYyRZK5GX6HYG68BP6inLglV3tDPqp6wcEa6Iuv4YGGnj/GpGiMtiujV+ imU2Ba5T9QoJrjN9SsMlg3nQDdEkhvyvvzbDWwXI68lfBFWYs/ZPmffbXiSHHP61hqo2 gu3DNNszxlj+7B2kco+iaW0CElACCVoFg23aeJ2n4EKSuK3KkBMKPgwOBrs22pqX8qMU uZm6JgrlubSmjr+mvbQ0tk7vU5BGtfjQFiU0tnvBjzD/6XM+3ov2kAGglueBzz4aBClu x/Lep1DVKDoVmbPK4UA5NW1hfJKheKBy6iOIjBvTgGmOg2Xhsgo3lZHCxRyMYLIlfwzK WCOQ== 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:date:subject:cc:to:from; bh=bQkq9G/R6xyQuejhWWJq42mGIe7yJEOkXD2d69YRFpg=; b=KbS65qUxLqdW0myhY0DS9B4I7cRmTyjJKOvVoxxxVrmQgLBHsdw5xtB8wEcOvSFfXN G0/MHy2BQH6RGmam2X2OaVuCOjxS6UG+VXLcQ39XjbfwsZCYAvt/YMCTPV5M2voLzeiL CTf5t4n9lAORaLBKsw9TT60tksYyPF7jyWkbmXtyGg5JDUScExVQpQtRyopfklz8JRVJ bbZQZmQQESLSmnuGCmoLZFi1ZGQUDrW58ps0IVkF7hm1Ytj0EXIUD/CckOaoKc3rQ28t 1DzBR25aARy8jNSQF2BPXskX9wXJjDeHrhcV3XI0msxmDHhVcfkRuIQbcW7A4kEVaF6J uYQQ== 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 u4si956148oic.115.2020.03.04.03.09.30; Wed, 04 Mar 2020 03:09:42 -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; 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 S1729384AbgCDLIC (ORCPT + 99 others); Wed, 4 Mar 2020 06:08:02 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:45242 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729286AbgCDLIB (ORCPT ); Wed, 4 Mar 2020 06:08:01 -0500 Received: from 79.184.237.41.ipv4.supernova.orange.pl (79.184.237.41) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.341) id 2bd8be21abd0c5ba; Wed, 4 Mar 2020 12:07:58 +0100 From: "Rafael J. Wysocki" To: madhuparnabhowmik10@gmail.com Cc: pavel@ucw.cz, len.brown@intel.com, gregkh@linuxfoundation.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, joel@joelfernandes.org, frextrite@gmail.com, linux-kernel-mentees@lists.linuxfoundation.org, paulmck@kernel.org Subject: Re: [PATCH 1/2] drivers: base: power: main.c: Use built-in RCU list checking Date: Wed, 04 Mar 2020 12:07:58 +0100 Message-ID: <1643853.WSYDh8IRHD@kreacher> In-Reply-To: <20200303194130.24617-1-madhuparnabhowmik10@gmail.com> References: <20200303194130.24617-1-madhuparnabhowmik10@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tuesday, March 3, 2020 8:41:30 PM CET madhuparnabhowmik10@gmail.com wrote: > From: Madhuparna Bhowmik > > This patch passes the cond argument to list_for_each_entry_rcu() > to fix the following false-positive lockdep warnings: > (with CONFIG_PROVE_RCU_LIST = y) > > [ 330.302784] ============================= > [ 330.302789] WARNING: suspicious RCU usage > [ 330.302796] 5.6.0-rc1+ #5 Not tainted > [ 330.302801] ----------------------------- > [ 330.302808] drivers/base/power/main.c:326 RCU-list traversed in non-reader section!! > > [ 330.303303] ============================= > [ 330.303307] WARNING: suspicious RCU usage > [ 330.303311] 5.6.0-rc1+ #5 Not tainted > [ 330.303315] ----------------------------- > [ 330.303319] drivers/base/power/main.c:1698 RCU-list traversed in non-reader section!! > > [ 331.934969] ============================= > [ 331.934971] WARNING: suspicious RCU usage > [ 331.934973] 5.6.0-rc1+ #5 Not tainted > [ 331.934975] ----------------------------- > [ 331.934977] drivers/base/power/main.c:1238 RCU-list traversed in non-reader section!! > > [ 332.467772] WARNING: suspicious RCU usage > [ 332.467775] 5.6.0-rc1+ #5 Not tainted > [ 332.467775] ----------------------------- > [ 332.467778] drivers/base/power/main.c:269 RCU-list traversed in non-reader section!! > > Signed-off-by: Madhuparna Bhowmik > --- > drivers/base/power/main.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c > index 0e99a760aebd..6d1dee7051eb 100644 > --- a/drivers/base/power/main.c > +++ b/drivers/base/power/main.c > @@ -40,6 +40,10 @@ > > typedef int (*pm_callback_t)(struct device *); > > +#define list_for_each_entry_rcu_locked(pos, head, member) \ > + list_for_each_entry_rcu(pos, head, member, \ > + device_links_read_lock_held()) > + > /* > * The entries in the dpm_list list are in a depth first order, simply > * because children are guaranteed to be discovered after parents, and > @@ -266,7 +270,7 @@ static void dpm_wait_for_suppliers(struct device *dev, bool async) > * callbacks freeing the link objects for the links in the list we're > * walking. > */ > - list_for_each_entry_rcu(link, &dev->links.suppliers, c_node) > + list_for_each_entry_rcu_locked(link, &dev->links.suppliers, c_node) > if (READ_ONCE(link->status) != DL_STATE_DORMANT) > dpm_wait(link->supplier, async); > > @@ -323,7 +327,7 @@ static void dpm_wait_for_consumers(struct device *dev, bool async) > * continue instead of trying to continue in parallel with its > * unregistration). > */ > - list_for_each_entry_rcu(link, &dev->links.consumers, s_node) > + list_for_each_entry_rcu_locked(link, &dev->links.consumers, s_node) > if (READ_ONCE(link->status) != DL_STATE_DORMANT) > dpm_wait(link->consumer, async); > > @@ -1235,7 +1239,7 @@ static void dpm_superior_set_must_resume(struct device *dev) > > idx = device_links_read_lock(); > > - list_for_each_entry_rcu(link, &dev->links.suppliers, c_node) > + list_for_each_entry_rcu_locked(link, &dev->links.suppliers, c_node) > link->supplier->power.must_resume = true; > > device_links_read_unlock(idx); > @@ -1695,7 +1699,7 @@ static void dpm_clear_superiors_direct_complete(struct device *dev) > > idx = device_links_read_lock(); > > - list_for_each_entry_rcu(link, &dev->links.suppliers, c_node) { > + list_for_each_entry_rcu_locked(link, &dev->links.suppliers, c_node) { > spin_lock_irq(&link->supplier->power.lock); > link->supplier->power.direct_complete = false; > spin_unlock_irq(&link->supplier->power.lock); > Applied along with the [2/2] (with updated changelogs) as 5.7 material. Thanks!