From: Herbert Xu <herbert@gondor.apana.org.au>
To: NeilBrown <neilb@suse.com>
Cc: Thomas Graf <tgraf@suug.ch>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] rhashtable: improve rhashtable_walk stability when stop/start used.
Date: Thu, 29 Mar 2018 13:50:20 +0800 [thread overview]
Message-ID: <20180329055020.GC21028@gondor.apana.org.au> (raw)
In-Reply-To: <152228634999.16370.13957181774415446375.stgit@noble>
On Thu, Mar 29, 2018 at 12:19:10PM +1100, NeilBrown wrote:
> When a walk of an rhashtable is interrupted with rhastable_walk_stop()
> and then rhashtable_walk_start(), the location to restart from is based
> on a 'skip' count in the current hash chain, and this can be incorrect
> if insertions or deletions have happened. This does not happen when
> the walk is not stopped and started as iter->p is a placeholder which
> is safe to use while holding the RCU read lock.
>
> In rhashtable_walk_start() we can revalidate that 'p' is still in the
> same hash chain. If it isn't then the current method is still used.
>
> With this patch, if a rhashtable walker ensures that the current
> object remains in the table over a stop/start period (possibly by
> elevating the reference count if that is sufficient), it can be sure
> that a walk will not miss objects that were in the hashtable for the
> whole time of the walk.
>
> rhashtable_walk_start() may not find the object even though it is
> still in the hashtable if a rehash has moved it to a new table. In
> this case it will (eventually) get -EAGAIN and will need to proceed
> through the whole table again to be sure to see everything at least
> once.
>
> Signed-off-by: NeilBrown <neilb@suse.com>
Very nice!
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
--
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
next prev parent reply other threads:[~2018-03-29 5:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-29 1:19 [PATCH 0/2] rhashtable_walk fixes NeilBrown
2018-03-29 1:19 ` [PATCH 1/2] rhashtable: fix insertion of in rhltable when duplicate found NeilBrown
2018-03-29 5:40 ` Herbert Xu
2018-03-29 1:19 ` [PATCH 2/2] rhashtable: improve rhashtable_walk stability when stop/start used NeilBrown
2018-03-29 5:50 ` Herbert Xu [this message]
2018-03-30 14:18 ` [PATCH 0/2] rhashtable_walk fixes David Miller
2018-04-03 2:23 ` NeilBrown
2018-04-03 2:34 ` David Miller
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=20180329055020.GC21028@gondor.apana.org.au \
--to=herbert@gondor.apana.org.au \
--cc=linux-kernel@vger.kernel.org \
--cc=neilb@suse.com \
--cc=netdev@vger.kernel.org \
--cc=tgraf@suug.ch \
/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®