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 5/6] rhashtable: support guaranteed successful insertion.
Date: Wed, 28 Mar 2018 18:04:40 +1100 [thread overview]
Message-ID: <87d0zo4r5j.fsf@notabene.neil.brown.name> (raw)
In-Reply-To: <20180328060432.GA16291@gondor.apana.org.au>
[-- Attachment #1: Type: text/plain, Size: 2667 bytes --]
On Wed, Mar 28 2018, Herbert Xu wrote:
> On Wed, Mar 28, 2018 at 08:34:19AM +1100, NeilBrown wrote:
>>
>> It is easy to get an -EBUSY insertion failure when .disable_count is
>> enabled, and I did get that. Blindly propagating that up caused lustre
>> to get terribly confused - not too surprising really.
>
> Right, so this failure mode is specific to your patch 6.
I disagree. My patch 6 only makes it common instead of exceedingly
rare. If any table in the list other than the first has a chain with 16
elements, then trying to insert an element with a hash which matches
that chain will fail with -EBUSY. This is theoretically possible
already, though astronomically unlikely. So that case will never be
tested for.
>
> I think I see the problem. As it currently stands, we never
> need growing when we hit the bucket length limit. We only do
> rehashes.
>
> With your patch, you must change it so that we actually try to
> grow the table if necessary when we hit the bucket length limit.
It is hard to know if it is necessary. And making the new table larger
will make the error less likely, but still won't make it impossible. So
callers will have to handle it - just like they currently have to handle
-ENOMEM even though it is highly unlikely (and not strictly necessary).
Are these errors ever actually useful? I thought I had convinced myself
before that they were (to throttle attacks on the hash function), but
they happen even less often than I thought.
>
> Otherwise it will result in the EBUSY that you're seeing.
>
> I laso think that we shouldn't make this a toggle. If we're going
> to do disable_count then it should be unconditionally done for
> everyone.
>
> However, I personally would prefer a percpu elem count instead of
> disabling it completely. Would that be acceptable to your use-case?
Maybe. Reading a percpu counter isn't cheap. Reading it whenever a hash
chain reaches 16 is reasonable, but I think we would want to read it a
lot more often than that. So probably store the last-sampled time (with
no locking) and only sample the counter if last-sampled is more than
jiffies - 10*HZ (???)
In the case in lustre we also shard the LRU list so that adding to the
LRU causes minimal contention. Keeping a shared counter together with
the lru is trivial and summing them periodically is little burden.
Maybe it makes sense to include that functionality if rhashtables so
that it is there for everyone.
A percpu counter uses a lot more memory than atomic_t. Given that some
callers set nelem_hint to 2 or 3, it seem likely that those callers
don't want to waste memory. Should we force them to?
Thanks,
NeilBrown
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
next prev parent reply other threads:[~2018-03-28 7:04 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 2/6] rhashtable: remove outdated comments about grow_decision etc 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
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 6/6] rhashtable: allow element counting to be disabled 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 [this message]
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 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=87d0zo4r5j.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).