From: NeilBrown <neilb@suse.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Thomas Graf <tgraf@suug.ch>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/6] rhashtable: allow a walk of the hash table without missing objects.
Date: Wed, 28 Mar 2018 18:17:57 +1100 [thread overview]
Message-ID: <87a7us4qje.fsf@notabene.neil.brown.name> (raw)
In-Reply-To: <20180328060734.GB16291@gondor.apana.org.au>
[-- Attachment #1: Type: text/plain, Size: 2246 bytes --]
On Wed, Mar 28 2018, Herbert Xu wrote:
> On Wed, Mar 28, 2018 at 08:54:41AM +1100, NeilBrown wrote:
>>
>> Possibly.
>> I particularly want the interface to require that you pass the
>> previously returned object to _continue. That makes it easy to see that
>> the object is still being used. If someone changes to code to delete
>> the object before the _continue, there should be a strong hint that it
>> won't work.
>>
>> Maybe it would be better to make it a WARN_ON()
>>
>> if (!obj || WARN_ON(iter->p != obj))
>> iter->p = NULL;
>
> This doesn't really protect against the case where obj is removed.
> All it proves is that the user saved a copy of obj which we already
> did anyway.
True. We ultimately need to trust the user not to do something silly.
We can do little things to help catch obvious errors though. That was
my intent with the WARN_ON.
>
> To detect an actual removal you'd need to traverse the list.
Yes. You could reset ->skip to zero and search for the given object.
That feels a bit like excess hand-holding to me, but probably wouldn't
be too expensive. It only happens when you need to drop out of RCU, and
in that case you are probably already doing something expensive.
>
> I have another idea: we could save insert the walkers into the
> hash table chain at the end, essentially as a hidden list. We
> can mark it with a flag like rht_marker so that normal traversal
> doesn't see it.
>
> That way the removal code can simply traverse that list and inform
> them that the iterator is invalid.
Sounds like over-kill to me.
It might be reasonable to have a CONFIG_DEBUG_RHASHTABLE which enables
extra to code to catch misuse, but I don't see the justification for
always performing these checks.
The DEBUG code could just scan the chain (usually quite short) to see if
the given element is present. Of course it might have already been
rehashed to the next table, so you would to allow for that possibility -
probably check tbl->rehash.
Thanks,
NeilBrown
>
> 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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
next prev parent reply other threads:[~2018-03-28 7:17 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-26 23:33 [PATCH 0/6] rhashtable: assorted fixes and enhancements NeilBrown
2018-03-26 23:33 ` [PATCH 4/6] rhashtable: allow a walk of the hash table without missing objects NeilBrown
2018-03-27 15:49 ` David Miller
2018-03-27 15:54 ` Herbert Xu
2018-03-27 21:50 ` NeilBrown
2018-03-27 15:51 ` Herbert Xu
2018-03-27 21:54 ` NeilBrown
2018-03-28 6:07 ` Herbert Xu
2018-03-28 7:17 ` NeilBrown [this message]
2018-03-28 7:30 ` Herbert Xu
2018-03-28 21:34 ` NeilBrown
2018-03-29 1:13 ` NeilBrown
2018-03-26 23:33 ` [PATCH 2/6] rhashtable: remove outdated comments about grow_decision etc NeilBrown
2018-03-26 23:33 ` [PATCH 5/6] rhashtable: support guaranteed successful insertion NeilBrown
2018-03-27 15:56 ` Herbert Xu
2018-03-27 21:34 ` NeilBrown
2018-03-28 6:04 ` Herbert Xu
2018-03-28 7:04 ` NeilBrown
2018-03-28 7:27 ` Herbert Xu
2018-03-28 21:26 ` NeilBrown
2018-03-29 5:22 ` Herbert Xu
2018-04-06 3:11 ` NeilBrown
2018-04-06 4:13 ` Herbert Xu
2018-03-26 23:33 ` [PATCH 6/6] rhashtable: allow element counting to be disabled NeilBrown
2018-03-26 23:33 ` [PATCH 1/6] rhashtable: improve documentation for rhashtable_walk_peek() NeilBrown
2018-03-27 10:55 ` Sergei Shtylyov
2018-03-27 15:30 ` Herbert Xu
2018-03-27 15:47 ` David Miller
2018-03-27 21:45 ` [PATCH 1/6 v2] " NeilBrown
2018-03-27 22:46 ` [PATCH 1/6] " Andreas Grünbacher
2018-03-28 0:49 ` NeilBrown
2018-03-26 23:33 ` [PATCH 3/6] rhashtable: reset intr when rhashtable_walk_start sees new table NeilBrown
2018-03-27 15:47 ` Herbert Xu
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=87a7us4qje.fsf@notabene.neil.brown.name \
--to=neilb@suse.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-kernel@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).