<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/lib/rhashtable.c, branch v4.0</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v4.0</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v4.0'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2015-02-27T22:55:14Z</updated>
<entry>
<title>rhashtable: use cond_resched()</title>
<updated>2015-02-27T22:55:14Z</updated>
<author>
<name>Eric Dumazet</name>
<email>edumazet@google.com</email>
</author>
<published>2015-02-26T15:20:34Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5beb5c90c1f54d745da040aa05634a5830ba4a4c'/>
<id>urn:sha1:5beb5c90c1f54d745da040aa05634a5830ba4a4c</id>
<content type='text'>
If a hash table has 128 slots and 16384 elems, expand to 256 slots
takes more than one second. For larger sets, a soft lockup is detected.

Holding cpu for that long, even in a work queue is a show stopper
for non preemptable kernels.

cond_resched() at strategic points to allow process scheduler
to reschedule us.

Signed-off-by: Eric Dumazet &lt;edumazet@google.com&gt;
Acked-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>rhashtable: remove indirection for grow/shrink decision functions</title>
<updated>2015-02-27T21:06:02Z</updated>
<author>
<name>Daniel Borkmann</name>
<email>daniel@iogearbox.net</email>
</author>
<published>2015-02-25T15:31:54Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=4c4b52d9b2df45e8216d3e30b5452e4a364d2cac'/>
<id>urn:sha1:4c4b52d9b2df45e8216d3e30b5452e4a364d2cac</id>
<content type='text'>
Currently, all real users of rhashtable default their grow and shrink
decision functions to rht_grow_above_75() and rht_shrink_below_30(),
so that there's currently no need to have this explicitly selectable.

It can/should be generic and private inside rhashtable until a real
use case pops up. Since we can make this private, we'll save us this
additional indirection layer and can improve insertion/deletion time
as well.

Reference: http://patchwork.ozlabs.org/patch/443040/
Suggested-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Acked-by: Thomas Graf &lt;tgraf@suug.ch&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>rhashtable: unconditionally grow when max_shift is not specified</title>
<updated>2015-02-27T21:06:02Z</updated>
<author>
<name>Daniel Borkmann</name>
<email>daniel@iogearbox.net</email>
</author>
<published>2015-02-25T15:31:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=8331de75cb13fc907ceba78e698c42150e61dda9'/>
<id>urn:sha1:8331de75cb13fc907ceba78e698c42150e61dda9</id>
<content type='text'>
While commit c0c09bfdc415 ("rhashtable: avoid unnecessary wakeup for
worker queue") rightfully moved part of the decision making of
whether we should expand or shrink from the expand/shrink functions
themselves into insert/delete functions in order to avoid unnecessary
worker wake-ups, it however introduced a regression by doing so.

Before that change, if no max_shift was specified (= 0) on rhashtable
initialization, rhashtable_expand() would just grow unconditionally
and lets the available memory be the limiting factor. After that
change, if no max_shift was specified, there would be _no_ expansion
step at all.

Given that netlink and tipc have a max_shift specified, it was not
visible there, but Josh Hunt reported that if nft that starts out
with a default element hint of 3 if not otherwise provided, would
slow i.e. inserts down trememdously as it cannot grow larger to
relax table occupancy.

Given that the test case verifies shrinks/expands manually, we also
must remove pointer to the helper functions to explicitly avoid
parallel resizing on insertions/deletions. test_bucket_stats() and
test_rht_lookup() could also be wrapped around rhashtable mutex to
explicitly synchronize a walk from resizing, but I think that defeats
the actual test case which intended to have explicit test steps,
i.e. 1) inserts, 2) expands, 3) shrinks, 4) deletions, with object
verification after each stage.

Reported-by: Josh Hunt &lt;johunt@akamai.com&gt;
Fixes: c0c09bfdc415 ("rhashtable: avoid unnecessary wakeup for worker queue")
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Cc: Ying Xue &lt;ying.xue@windriver.com&gt;
Cc: Josh Hunt &lt;johunt@akamai.com&gt;
Acked-by: Thomas Graf &lt;tgraf@suug.ch&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>rhashtable: initialize all rhashtable walker members</title>
<updated>2015-02-23T20:23:19Z</updated>
<author>
<name>Sasha Levin</name>
<email>sasha.levin@oracle.com</email>
</author>
<published>2015-02-23T09:35:06Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=71bb0012c38fbd090a56b3cb96e9f626c415d264'/>
<id>urn:sha1:71bb0012c38fbd090a56b3cb96e9f626c415d264</id>
<content type='text'>
Commit f2dba9c6ff ("rhashtable: Introduce rhashtable_walk_*") forgot to
initialize the members of struct rhashtable_walker after allocating it, which
caused an undefined value for 'resize' which is used later on.

Fixes: f2dba9c6ff ("rhashtable: Introduce rhashtable_walk_*")
Signed-off-by: Sasha Levin &lt;sasha.levin@oracle.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>rhashtable: better high order allocation attempts</title>
<updated>2015-02-20T22:38:09Z</updated>
<author>
<name>Daniel Borkmann</name>
<email>daniel@iogearbox.net</email>
</author>
<published>2015-02-19T23:53:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=eb6d1abf1bd8bf1beb45b5401c8324bdb8f893c4'/>
<id>urn:sha1:eb6d1abf1bd8bf1beb45b5401c8324bdb8f893c4</id>
<content type='text'>
When trying to allocate future tables via bucket_table_alloc(), it seems
overkill on large table shifts that we probe for kzalloc() unconditionally
first, as it's likely to fail.

Only probe with kzalloc() for more reasonable table sizes and use vzalloc()
either as a fallback on failure or directly in case of large table sizes.

Fixes: 7e1e77636e36 ("lib: Resizable, Scalable, Concurrent Hash Table")
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Acked-by: Thomas Graf &lt;tgraf@suug.ch&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>rhashtable: don't test for shrink on insert, expansion on delete</title>
<updated>2015-02-20T22:38:09Z</updated>
<author>
<name>Daniel Borkmann</name>
<email>daniel@iogearbox.net</email>
</author>
<published>2015-02-19T23:53:37Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=342100d937ed6e5faf1e7ee7dcd7b3935fec8877'/>
<id>urn:sha1:342100d937ed6e5faf1e7ee7dcd7b3935fec8877</id>
<content type='text'>
Restore pre 54c5b7d311c8 behaviour and only probe for expansions on inserts
and shrinks on deletes. Currently, it will happen that on initial inserts
into a sparse hash table, we may i.e. shrink it first simply because it's
not fully populated yet, only to later realize that we need to grow again.

This however is counter intuitive, e.g. an initial default size of 64
elements is already small enough, and in case an elements size hint is given
to the hash table by a user, we should avoid unnecessary expansion steps,
so a shrink is clearly unintended here.

Fixes: 54c5b7d311c8 ("rhashtable: introduce rhashtable_wakeup_worker helper function")
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Cc: Ying Xue &lt;ying.xue@windriver.com&gt;
Acked-by: Thomas Graf &lt;tgraf@suug.ch&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>rhashtable: using ERR_PTR requires linux/err.h</title>
<updated>2015-02-09T05:52:24Z</updated>
<author>
<name>Stephen Rothwell</name>
<email>sfr@canb.auug.org.au</email>
</author>
<published>2015-02-09T03:04:03Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=61d7b097738c9e37f7d5dcb1adf54a54d34444f7'/>
<id>urn:sha1:61d7b097738c9e37f7d5dcb1adf54a54d34444f7</id>
<content type='text'>
Signed-off-by: Stephen Rothwell &lt;sfr@canb.auug.org.au&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>rhashtable: Fix remove logic to avoid cross references between buckets</title>
<updated>2015-02-06T23:19:17Z</updated>
<author>
<name>Thomas Graf</name>
<email>tgraf@suug.ch</email>
</author>
<published>2015-02-06T16:08:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=020219a69d40a205dad12b0ea1e6a46153793368'/>
<id>urn:sha1:020219a69d40a205dad12b0ea1e6a46153793368</id>
<content type='text'>
The remove logic properly searched the remaining chain for a matching
entry with an identical hash but it did this while searching from both
the old and new table. Instead in order to not leave stale references
behind we need to:

 1. When growing and searching from the new table:
    Search remaining chain for entry with same hash to avoid having
    the new table directly point to a entry with a different hash.

 2. When shrinking and searching from the old table:
    Check if the element after the removed would create a cross
    reference and avoid it if so.

These bugs were present from the beginning in nft_hash.

Also, both insert functions calculated the hash based on the mask of
the new table. This worked while growing. Wwhile shrinking, the mask
of the inew table is smaller than the mask of the old table. This lead
to a bit not being taken into account when selecting the bucket lock
and thus caused the wrong bucket to be locked eventually.

Fixes: 7e1e77636e36 ("lib: Resizable, Scalable, Concurrent Hash Table")
Fixes: 97defe1ecf86 ("rhashtable: Per bucket locks &amp; deferred expansion/shrinking")
Reported-by: Ying Xue &lt;ying.xue@windriver.com&gt;
Signed-off-by: Thomas Graf &lt;tgraf@suug.ch&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>rhashtable: Avoid bucket cross reference after removal</title>
<updated>2015-02-06T23:18:35Z</updated>
<author>
<name>Thomas Graf</name>
<email>tgraf@suug.ch</email>
</author>
<published>2015-02-05T01:03:36Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=cf52d52f9ccb9966ac019d9f79824195583e3e6c'/>
<id>urn:sha1:cf52d52f9ccb9966ac019d9f79824195583e3e6c</id>
<content type='text'>
During a resize, when two buckets in the larger table map to
a single bucket in the smaller table and the new table has already
been (partially) linked to the old table. Removal of an element
may result the bucket in the larger table to point to entries
which all hash to a different value than the bucket index. Thus
causing two buckets to point to the same sub chain after unzipping.
This is not illegal *during* the resize phase but after it has
completed.

Keep the old table around until all of the unzipping is done to
allow the removal code to only search for matching hashed entries
during this special period.

Reported-by: Ying Xue &lt;ying.xue@windriver.com&gt;
Fixes: 97defe1ecf86 ("rhashtable: Per bucket locks &amp; deferred expansion/shrinking")
Signed-off-by: Thomas Graf &lt;tgraf@suug.ch&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>rhashtable: Add more lock verification</title>
<updated>2015-02-06T23:18:34Z</updated>
<author>
<name>Thomas Graf</name>
<email>tgraf@suug.ch</email>
</author>
<published>2015-02-05T01:03:35Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=7cd10db8de2b6a32ccabef2e0e01c7444faa49d4'/>
<id>urn:sha1:7cd10db8de2b6a32ccabef2e0e01c7444faa49d4</id>
<content type='text'>
Catch hash miscalculations which result in hard to track down race
conditions.

Signed-off-by: Thomas Graf &lt;tgraf@suug.ch&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
</feed>
