From: madhuparnabhowmik10@gmail.com
To: rjw@rjwysocki.net, pavel@ucw.cz, len.brown@intel.com,
gregkh@linuxfoundation.org
Cc: 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,
Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
Subject: [PATCH 1/2] drivers: base: power: main.c: Use built-in RCU list checking
Date: Wed, 4 Mar 2020 01:11:30 +0530 [thread overview]
Message-ID: <20200303194130.24617-1-madhuparnabhowmik10@gmail.com> (raw)
From: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
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 <madhuparnabhowmik10@gmail.com>
---
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);
--
2.17.1
next reply other threads:[~2020-03-03 19:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-03 19:41 madhuparnabhowmik10 [this message]
2020-03-04 11:07 ` Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200303194130.24617-1-madhuparnabhowmik10@gmail.com \
--to=madhuparnabhowmik10@gmail.com \
--cc=frextrite@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=joel@joelfernandes.org \
--cc=len.brown@intel.com \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=paulmck@kernel.org \
--cc=pavel@ucw.cz \
--cc=rjw@rjwysocki.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®