All of lore.kernel.org
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: kernel test robot <ying.huang@linux.intel.com>,
	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: Re: rhashtable: Kill harmless RCU warning in rhashtable_walk_init
Date: Fri, 18 Dec 2015 21:14:08 +0800	[thread overview]
Message-ID: <20151218131408.GA21756@gondor.apana.org.au> (raw)
In-Reply-To: <1450443254.8474.120.camel@edumazet-glaptop2.roam.corp.google.com>

On Fri, Dec 18, 2015 at 04:54:14AM -0800, Eric Dumazet wrote:
>
> You can avoid the comment by using the self documented and lockdep
> enabled primitive
> 
> iter->walker->tbl = rcu_dereference_protected(ht->tbl,
> 					      lockdep_is_held(&ht->lock));

That is just gross.  I think a comment is much better in this case.

If we were to have more place where ht->lock is taken and we had
to do the RCU dereference on ht->tbl then we could add a helper
for it.  For now it's just a single place and I think a comment
is the best way to deal with it.

> But, storing the ht->tbl and then releasing the lock immediately after
> escapes RCU protection.
> 
> So why do we store ht->tbl in the first place ?
> 
> What exactly prevents it from disappearing after lock is released ?

We add ourselves to the walker list before we release the lock.
The only entity that can destroy ht->tbl will take care of all
walkers before doing so.

Cheers,
-- 
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

WARNING: multiple messages have this Message-ID
From: Herbert Xu <herbert@gondor.apana.org.au>
To: lkp@lists.01.org
Subject: Re: rhashtable: Kill harmless RCU warning in rhashtable_walk_init
Date: Fri, 18 Dec 2015 21:14:08 +0800	[thread overview]
Message-ID: <20151218131408.GA21756@gondor.apana.org.au> (raw)
In-Reply-To: <1450443254.8474.120.camel@edumazet-glaptop2.roam.corp.google.com>

[-- Attachment #1: Type: text/plain, Size: 1126 bytes --]

On Fri, Dec 18, 2015 at 04:54:14AM -0800, Eric Dumazet wrote:
>
> You can avoid the comment by using the self documented and lockdep
> enabled primitive
> 
> iter->walker->tbl = rcu_dereference_protected(ht->tbl,
> 					      lockdep_is_held(&ht->lock));

That is just gross.  I think a comment is much better in this case.

If we were to have more place where ht->lock is taken and we had
to do the RCU dereference on ht->tbl then we could add a helper
for it.  For now it's just a single place and I think a comment
is the best way to deal with it.

> But, storing the ht->tbl and then releasing the lock immediately after
> escapes RCU protection.
> 
> So why do we store ht->tbl in the first place ?
> 
> What exactly prevents it from disappearing after lock is released ?

We add ourselves to the walker list before we release the lock.
The only entity that can destroy ht->tbl will take care of all
walkers before doing so.

Cheers,
-- 
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 13:14 UTC|newest]

Thread overview: 18+ 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  1:39 ` kernel test robot
2015-12-18  5:34 ` [lkp] " Herbert Xu
2015-12-18  5:34   ` Herbert Xu
2015-12-18  6:24   ` rhashtable: Kill harmless RCU warning in rhashtable_walk_init Herbert Xu
2015-12-18  6:24     ` Herbert Xu
2015-12-18 12:54     ` Eric Dumazet
2015-12-18 12:54       ` Eric Dumazet
2015-12-18 13:14       ` Herbert Xu [this message]
2015-12-18 13:14         ` Herbert Xu
2015-12-18 21:27         ` David Miller
2015-12-18 21:27           ` David Miller
2015-12-19  2:45           ` [PATCH v2] " Herbert Xu
2015-12-19  2:45             ` Herbert Xu
2015-12-19  4:42             ` David Miller
2015-12-19  4:42               ` David Miller
2015-12-19  4:47               ` [LKP] " Fengguang Wu
2015-12-19  4:47                 ` 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=20151218131408.GA21756@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=colin.king@canonical.com \
    --cc=eric.dumazet@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.