Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1294441

Re: [lkp] [rhashtable] f9f51b8070: INFO: suspicious RCU usage. ]

From Herbert Xu <herbert@gondor.apana.org.au>
Newsgroups linux.kernel
Subject Re: [lkp] [rhashtable] f9f51b8070: INFO: suspicious RCU usage. ]
Date 2015-12-18 06:40 +0100
Message-ID <qGVVL-1qO-3@gated-at.bofh.it> (permalink)
References <qGSbv-7rk-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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.

---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.

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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Re: [lkp] [rhashtable] f9f51b8070: INFO: suspicious RCU usage. ] Herbert Xu <herbert@gondor.apana.org.au> - 2015-12-18 06:40 +0100
  rhashtable: Kill harmless RCU warning in rhashtable_walk_init Herbert Xu <herbert@gondor.apana.org.au> - 2015-12-18 07:30 +0100
    Re: rhashtable: Kill harmless RCU warning in rhashtable_walk_init Eric Dumazet <eric.dumazet@gmail.com> - 2015-12-18 14:00 +0100
      Re: rhashtable: Kill harmless RCU warning in rhashtable_walk_init Herbert Xu <herbert@gondor.apana.org.au> - 2015-12-18 14:20 +0100
        Re: rhashtable: Kill harmless RCU warning in rhashtable_walk_init David Miller <davem@davemloft.net> - 2015-12-18 22:30 +0100
          [PATCH v2] rhashtable: Kill harmless RCU warning in  rhashtable_walk_init Herbert Xu <herbert@gondor.apana.org.au> - 2015-12-19 03:50 +0100
            Re: [LKP] [PATCH v2] rhashtable: Kill harmless RCU warning in  rhashtable_walk_init Fengguang Wu <fengguang.wu@intel.com> - 2015-12-19 05:50 +0100
            Re: [PATCH v2] rhashtable: Kill harmless RCU warning in  rhashtable_walk_init David Miller <davem@davemloft.net> - 2015-12-19 05:50 +0100

csiph-web