<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/lib/rhashtable.c, branch v4.8</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.8</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v4.8'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2016-08-27T04:59:53Z</updated>
<entry>
<title>rhashtable: fix a memory leak in alloc_bucket_locks()</title>
<updated>2016-08-27T04:59:53Z</updated>
<author>
<name>Eric Dumazet</name>
<email>edumazet@google.com</email>
</author>
<published>2016-08-26T15:51:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=9dbeea7f08f3784b152d9fb3b86beb34aad77c72'/>
<id>urn:sha1:9dbeea7f08f3784b152d9fb3b86beb34aad77c72</id>
<content type='text'>
If vmalloc() was successful, do not attempt a kmalloc_array()

Fixes: 4cf0b354d92e ("rhashtable: avoid large lock-array allocations")
Reported-by: CAI Qian &lt;caiqian@redhat.com&gt;
Signed-off-by: Eric Dumazet &lt;edumazet@google.com&gt;
Cc: Florian Westphal &lt;fw@strlen.de&gt;
Acked-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
Tested-by: CAI Qian &lt;caiqian@redhat.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>rhashtable: fix shift by 64 when shrinking</title>
<updated>2016-08-15T18:10:09Z</updated>
<author>
<name>Vegard Nossum</name>
<email>vegard.nossum@oracle.com</email>
</author>
<published>2016-08-12T18:10:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=12311959ecf8a3a64676c01b62ce67a0c5f0fd49'/>
<id>urn:sha1:12311959ecf8a3a64676c01b62ce67a0c5f0fd49</id>
<content type='text'>
I got this:

    ================================================================================
    UBSAN: Undefined behaviour in ./include/linux/log2.h:63:13
    shift exponent 64 is too large for 64-bit type 'long unsigned int'
    CPU: 1 PID: 721 Comm: kworker/1:1 Not tainted 4.8.0-rc1+ #87
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.9.3-0-ge2fc41e-prebuilt.qemu-project.org 04/01/2014
    Workqueue: events rht_deferred_worker
     0000000000000000 ffff88011661f8d8 ffffffff82344f50 0000000041b58ab3
     ffffffff84f98000 ffffffff82344ea4 ffff88011661f900 ffff88011661f8b0
     0000000000000001 ffff88011661f6b8 dffffc0000000000 ffffffff867f7640
    Call Trace:
     [&lt;ffffffff82344f50&gt;] dump_stack+0xac/0xfc
     [&lt;ffffffff82344ea4&gt;] ? _atomic_dec_and_lock+0xc4/0xc4
     [&lt;ffffffff8242f5b8&gt;] ubsan_epilogue+0xd/0x8a
     [&lt;ffffffff82430c41&gt;] __ubsan_handle_shift_out_of_bounds+0x255/0x29a
     [&lt;ffffffff824309ec&gt;] ? __ubsan_handle_out_of_bounds+0x180/0x180
     [&lt;ffffffff84003436&gt;] ? nl80211_req_set_reg+0x256/0x2f0
     [&lt;ffffffff812112ba&gt;] ? print_context_stack+0x8a/0x160
     [&lt;ffffffff81200031&gt;] ? amd_pmu_reset+0x341/0x380
     [&lt;ffffffff823af808&gt;] rht_deferred_worker+0x1618/0x1790
     [&lt;ffffffff823af808&gt;] ? rht_deferred_worker+0x1618/0x1790
     [&lt;ffffffff823ae1f0&gt;] ? rhashtable_jhash2+0x370/0x370
     [&lt;ffffffff8134c12d&gt;] ? process_one_work+0x6fd/0x1970
     [&lt;ffffffff8134c1cf&gt;] process_one_work+0x79f/0x1970
     [&lt;ffffffff8134c12d&gt;] ? process_one_work+0x6fd/0x1970
     [&lt;ffffffff8134ba30&gt;] ? try_to_grab_pending+0x4c0/0x4c0
     [&lt;ffffffff8134d564&gt;] ? worker_thread+0x1c4/0x1340
     [&lt;ffffffff8134d8ff&gt;] worker_thread+0x55f/0x1340
     [&lt;ffffffff845e904f&gt;] ? __schedule+0x4df/0x1d40
     [&lt;ffffffff8134d3a0&gt;] ? process_one_work+0x1970/0x1970
     [&lt;ffffffff8134d3a0&gt;] ? process_one_work+0x1970/0x1970
     [&lt;ffffffff813642f7&gt;] kthread+0x237/0x390
     [&lt;ffffffff813640c0&gt;] ? __kthread_parkme+0x280/0x280
     [&lt;ffffffff845f8c93&gt;] ? _raw_spin_unlock_irq+0x33/0x50
     [&lt;ffffffff845f95df&gt;] ret_from_fork+0x1f/0x40
     [&lt;ffffffff813640c0&gt;] ? __kthread_parkme+0x280/0x280
    ================================================================================

roundup_pow_of_two() is undefined when called with an argument of 0, so
let's avoid the call and just fall back to ht-&gt;p.min_size (which should
never be smaller than HASH_MIN_SIZE).

Cc: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
Signed-off-by: Vegard Nossum &lt;vegard.nossum@oracle.com&gt;
Acked-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>rhashtable: avoid large lock-array allocations</title>
<updated>2016-08-15T04:12:57Z</updated>
<author>
<name>Florian Westphal</name>
<email>fw@strlen.de</email>
</author>
<published>2016-08-12T10:03:52Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=4cf0b354d92ee2c642532ee39e330f8f580fd985'/>
<id>urn:sha1:4cf0b354d92ee2c642532ee39e330f8f580fd985</id>
<content type='text'>
Sander reports following splat after netfilter nat bysrc table got
converted to rhashtable:

swapper/0: page allocation failure: order:3, mode:0x2084020(GFP_ATOMIC|__GFP_COMP)
 CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.8.0-rc1 [..]
 [&lt;ffffffff811633ed&gt;] warn_alloc_failed+0xdd/0x140
 [&lt;ffffffff811638b1&gt;] __alloc_pages_nodemask+0x3e1/0xcf0
 [&lt;ffffffff811a72ed&gt;] alloc_pages_current+0x8d/0x110
 [&lt;ffffffff8117cb7f&gt;] kmalloc_order+0x1f/0x70
 [&lt;ffffffff811aec19&gt;] __kmalloc+0x129/0x140
 [&lt;ffffffff8146d561&gt;] bucket_table_alloc+0xc1/0x1d0
 [&lt;ffffffff8146da1d&gt;] rhashtable_insert_rehash+0x5d/0xe0
 [&lt;ffffffff819fcfff&gt;] nf_nat_setup_info+0x2ef/0x400

The failure happens when allocating the spinlock array.
Even with GFP_KERNEL its unlikely for such a large allocation
to succeed.

Thomas Graf pointed me at inet_ehash_locks_alloc(), so in addition
to adding NOWARN for atomic allocations this also makes the bucket-array
sizing more conservative.

In commit 095dc8e0c3686 ("tcp: fix/cleanup inet_ehash_locks_alloc()"),
Eric Dumazet says: "Budget 2 cache lines per cpu worth of 'spinlocks'".
IOW, consider size needed by a single spinlock when determining
number of locks per cpu.  So with 64 byte per cacheline and 4 byte per
spinlock this gives 32 locks per cpu.

Resulting size of the lock-array (sizeof(spinlock) == 4):

cpus:    1   2   4   8   16   32   64
old:    1k  1k  4k  8k  16k  16k  16k
new:   128 256 512  1k   2k   4k   8k

8k allocation should have decent chance of success even
with GFP_ATOMIC, and should not fail with GFP_KERNEL.

With 72-byte spinlock (LOCKDEP):
cpus :   1   2
old:    9k 18k
new:   ~2k ~4k

Reported-by: Sander Eikelenboom &lt;linux@eikelenboom.it&gt;
Suggested-by: Thomas Graf &lt;tgraf@suug.ch&gt;
Signed-off-by: Florian Westphal &lt;fw@strlen.de&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>rhashtable: accept GFP flags in rhashtable_walk_init</title>
<updated>2016-04-05T08:56:32Z</updated>
<author>
<name>Bob Copeland</name>
<email>me@bobcopeland.com</email>
</author>
<published>2016-03-02T15:09:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=8f6fd83c6c5ec66a4a70c728535ddcdfef4f3697'/>
<id>urn:sha1:8f6fd83c6c5ec66a4a70c728535ddcdfef4f3697</id>
<content type='text'>
In certain cases, the 802.11 mesh pathtable code wants to
iterate over all of the entries in the forwarding table from
the receive path, which is inside an RCU read-side critical
section.  Enable walks inside atomic sections by allowing
GFP_ATOMIC allocations for the walker state.

Change all existing callsites to pass in GFP_KERNEL.

Acked-by: Thomas Graf &lt;tgraf@suug.ch&gt;
Signed-off-by: Bob Copeland &lt;me@bobcopeland.com&gt;
[also adjust gfs2/glock.c and rhashtable tests]
Signed-off-by: Johannes Berg &lt;johannes.berg@intel.com&gt;
</content>
</entry>
<entry>
<title>Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net</title>
<updated>2015-12-31T23:20:10Z</updated>
<author>
<name>David S. Miller</name>
<email>davem@davemloft.net</email>
</author>
<published>2015-12-31T23:20:10Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=c07f30ad68053181b3e8a0e65b0630e12e844f91'/>
<id>urn:sha1:c07f30ad68053181b3e8a0e65b0630e12e844f91</id>
<content type='text'>
</content>
</entry>
<entry>
<title>rhashtable: Kill harmless RCU warning in rhashtable_walk_init</title>
<updated>2015-12-19T04:44:18Z</updated>
<author>
<name>Herbert Xu</name>
<email>herbert@gondor.apana.org.au</email>
</author>
<published>2015-12-19T02:45:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=179ccc0a73641ffd24e44ff10a7bd494efe98d8d'/>
<id>urn:sha1:179ccc0a73641ffd24e44ff10a7bd494efe98d8d</id>
<content type='text'>
The commit c6ff5268293ef98e48a99597e765ffc417e39fa5 ("rhashtable:
Fix walker list corruption") causes a suspicious RCU usage warning
because we no longer hold ht-&gt;mutex when we dereference ht-&gt;tbl.

However, this is a false positive because we now hold ht-&gt;lock
which also guarantees that ht-&gt;tbl won't disppear from under us.

This patch kills the warning by using rcu_dereference_protected.

Reported-by: kernel test robot &lt;ying.huang@linux.intel.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net</title>
<updated>2015-12-18T03:08:28Z</updated>
<author>
<name>David S. Miller</name>
<email>davem@davemloft.net</email>
</author>
<published>2015-12-18T03:08:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b3e0d3d7bab14f2544a3314bec53a23dc7dd2206'/>
<id>urn:sha1:b3e0d3d7bab14f2544a3314bec53a23dc7dd2206</id>
<content type='text'>
Conflicts:
	drivers/net/geneve.c

Here we had an overlapping change, where in 'net' the extraneous stats
bump was being removed whilst in 'net-next' the final argument to
udp_tunnel6_xmit_skb() was being changed.

Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>rhashtable: Fix walker list corruption</title>
<updated>2015-12-16T16:13:14Z</updated>
<author>
<name>Herbert Xu</name>
<email>herbert@gondor.apana.org.au</email>
</author>
<published>2015-12-16T08:45:54Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=c6ff5268293ef98e48a99597e765ffc417e39fa5'/>
<id>urn:sha1:c6ff5268293ef98e48a99597e765ffc417e39fa5</id>
<content type='text'>
The commit ba7c95ea3870fe7b847466d39a049ab6f156aa2c ("rhashtable:
Fix sleeping inside RCU critical section in walk_stop") introduced
a new spinlock for the walker list.  However, it did not convert
all existing users of the list over to the new spin lock.  Some
continued to use the old mutext for this purpose.  This obviously
led to corruption of the list.

The fix is to use the spin lock everywhere where we touch the list.

This also allows us to do rcu_rad_lock before we take the lock in
rhashtable_walk_start.  With the old mutex this would've deadlocked
but it's safe with the new spin lock.

Fixes: ba7c95ea3870 ("rhashtable: Fix sleeping inside RCU...")
Reported-by: Colin Ian King &lt;colin.king@canonical.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>rhashtable: Enforce minimum size on initial hash table</title>
<updated>2015-12-16T15:44:08Z</updated>
<author>
<name>Herbert Xu</name>
<email>herbert@gondor.apana.org.au</email>
</author>
<published>2015-12-16T10:13:14Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=3a324606bbabfc30084ce9d08169910773ba9a92'/>
<id>urn:sha1:3a324606bbabfc30084ce9d08169910773ba9a92</id>
<content type='text'>
William Hua &lt;william.hua@canonical.com&gt; wrote:
&gt;
&gt; I wasn't aware there was an enforced minimum size. I simply set the
&gt; nelem_hint in the rhastable_params struct to 1, expecting it to grow as
&gt; needed. This caused a segfault afterwards when trying to insert an
&gt; element.

OK we're doing the size computation before we enforce the limit
on min_size.

---8&lt;---
We need to do the initial hash table size computation after we
have obtained the correct min_size/max_size parameters.  Otherwise
we may end up with a hash table whose size is outside the allowed
envelope.

Fixes: a998f712f77e ("rhashtable: Round up/down min/max_size to...")
Reported-by: William Hua &lt;william.hua@canonical.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>rhashtable: Remove unnecessary wmb for future_tbl</title>
<updated>2015-12-09T03:46:32Z</updated>
<author>
<name>Herbert Xu</name>
<email>herbert@gondor.apana.org.au</email>
</author>
<published>2015-12-08T09:09:04Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=46c749eac979c0bf280f760971367e9babe4d05f'/>
<id>urn:sha1:46c749eac979c0bf280f760971367e9babe4d05f</id>
<content type='text'>
The patch 9497df88ab5567daa001829051c5f87161a81ff0 ("rhashtable:
Fix reader/rehash race") added a pair of barriers.  In fact the
wmb is superfluous because every subsequent write to the old or
new hash table uses rcu_assign_pointer, which itself carriers a
full barrier prior to the assignment.

Therefore we may remove the explicit wmb.

Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
Acked-by: Thomas Graf &lt;tgraf@suug.ch&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
</feed>
