linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: kernel test robot <ying.huang@linux.intel.com>
Cc: lkp@01.org, LKML <linux-kernel@vger.kernel.org>,
	Colin Ian King <colin.king@canonical.com>,
	0day robot <fengguang.wu@intel.com>,
	netdev@vger.kernel.org
Subject: rhashtable: Kill harmless RCU warning in rhashtable_walk_init
Date: Fri, 18 Dec 2015 14:24:50 +0800	[thread overview]
Message-ID: <20151218062450.GA19749@gondor.apana.org.au> (raw)
In-Reply-To: <20151218053416.GA19479@gondor.apana.org.au>

On Fri, Dec 18, 2015 at 01:34:16PM +0800, Herbert Xu wrote:
> On Fri, Dec 18, 2015 at 09:39:22AM +0800, kernel test robot wrote:
> > FYI, we noticed the below changes on
> > 
> > https://github.com/0day-ci/linux Herbert-Xu/rhashtable-Fix-walker-list-corruption/20151216-164833
> > commit f9f51b8070be3e829100614a7372b219723b864f ("rhashtable: Fix walker list corruption")
> > 
> > [    8.933376] ===============================
> > [    8.933376] ===============================
> > [    8.934629] [ INFO: suspicious RCU usage. ]
> > [    8.934629] [ INFO: suspicious RCU usage. ]
> > [    8.935941] 4.4.0-rc3-00995-gf9f51b8 #2 Not tainted
> > [    8.935941] 4.4.0-rc3-00995-gf9f51b8 #2 Not tainted
> > [    8.937494] -------------------------------
> > [    8.937494] -------------------------------
> > [    8.938818] lib/rhashtable.c:504 suspicious rcu_dereference_protected() usage!
> > [    8.938818] lib/rhashtable.c:504 suspicious rcu_dereference_protected() usage!
> 
> This is actually a false positive because the new spin lock that
> we hold prevents ht->tbl from disappearing under us.  So here is
> a patch to kill the warning with a comment.

Resent with a proper patch subject and reported-by.

---8<---
The commit f9f51b8070be3e829100614a7372b219723b864f ("rhashtable:
Fix walker list corruption") causes a suspicious RCU usage warning
because we no longer hold ht->mutex when we dereference ht->tbl.

However, this is a false positive because we now hold ht->lock
which also guarantees that ht->tbl won't disppear from under us.

This patch kills the warning by using rcu_dereference_raw and
adding a comment.

Reported-by: kernel test robot <ying.huang@linux.intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

diff --git a/lib/rhashtable.c b/lib/rhashtable.c
index eb9240c..3404b06 100644
--- a/lib/rhashtable.c
+++ b/lib/rhashtable.c
@@ -519,7 +519,11 @@ int rhashtable_walk_init(struct rhashtable *ht, struct rhashtable_iter *iter)
 		return -ENOMEM;
 
 	spin_lock(&ht->lock);
-	iter->walker->tbl = rht_dereference(ht->tbl, ht);
+	/* We do not need RCU protection because we hold ht->lock
+	 * which guarantees that if we see ht->tbl then it won't
+	 * die on us.
+	 */
+	iter->walker->tbl = rcu_dereference_raw(ht->tbl);
 	list_add(&iter->walker->list, &iter->walker->tbl->walkers);
 	spin_unlock(&ht->lock);
 
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

  reply	other threads:[~2015-12-18  6:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-18  1:39 [lkp] [rhashtable] f9f51b8070: INFO: suspicious RCU usage. ] kernel test robot
2015-12-18  5:34 ` Herbert Xu
2015-12-18  6:24   ` Herbert Xu [this message]
2015-12-18 12:54     ` rhashtable: Kill harmless RCU warning in rhashtable_walk_init Eric Dumazet
2015-12-18 13:14       ` Herbert Xu
2015-12-18 21:27         ` David Miller
2015-12-19  2:45           ` [PATCH v2] " Herbert Xu
2015-12-19  4:42             ` David Miller
2015-12-19  4:47               ` [LKP] " Fengguang Wu

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=20151218062450.GA19749@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=colin.king@canonical.com \
    --cc=fengguang.wu@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@01.org \
    --cc=netdev@vger.kernel.org \
    --cc=ying.huang@linux.intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).