Message ID | E1YWMLC-0000CE-RS@gondolin.me.apana.org.au |
---|---|
State | Changes Requested, archived |
Delegated to: | David Miller |
Headers | show |
On 03/13/15 at 08:57pm, Herbert Xu wrote: > @@ -58,7 +59,8 @@ struct rhash_head { > * @buckets: size * hash buckets > */ > struct bucket_table { > - size_t size; > + unsigned int size; > + unsigned int rehash; > u32 hash_rnd; > u32 shift; > unsigned int locks_mask; This changes causes a minor warning: lib/test_rhashtable.c: In function ‘test_bucket_stats’: lib/test_rhashtable.c:83:4: warning: format ‘%zu’ expects argument of type ‘size_t’, but argument 3 has type ‘unsigned int’ [-Wformat=] pr_info(" [%#4x/%zu]", i, tbl->size) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Fri, Mar 13, 2015 at 01:51:31PM +0000, Thomas Graf wrote: > On 03/13/15 at 08:57pm, Herbert Xu wrote: > > @@ -58,7 +59,8 @@ struct rhash_head { > > * @buckets: size * hash buckets > > */ > > struct bucket_table { > > - size_t size; > > + unsigned int size; > > + unsigned int rehash; > > u32 hash_rnd; > > u32 shift; > > unsigned int locks_mask; > > This changes causes a minor warning: > lib/test_rhashtable.c: In function ‘test_bucket_stats’: > lib/test_rhashtable.c:83:4: warning: format ‘%zu’ expects argument of > type ‘size_t’, but argument 3 has type ‘unsigned int’ [-Wformat=] > pr_info(" [%#4x/%zu]", i, tbl->size) Thanks. I have now enabled test_rhashtable in my config so I should be able to catch it next time.
diff --git a/include/linux/rhashtable.h b/include/linux/rhashtable.h index a0abddd..ed7562a 100644 --- a/include/linux/rhashtable.h +++ b/include/linux/rhashtable.h @@ -49,6 +49,7 @@ struct rhash_head { /** * struct bucket_table - Table of hash buckets * @size: Number of hash buckets + * @rehash: Current bucket being rehashed * @hash_rnd: Random seed to fold into hash * @shift: Current size (1 << shift) * @locks_mask: Mask to apply before accessing locks[] @@ -58,7 +59,8 @@ struct rhash_head { * @buckets: size * hash buckets */ struct bucket_table { - size_t size; + unsigned int size; + unsigned int rehash; u32 hash_rnd; u32 shift; unsigned int locks_mask; diff --git a/lib/rhashtable.c b/lib/rhashtable.c index 36fb091..ff4ea17 100644 --- a/lib/rhashtable.c +++ b/lib/rhashtable.c @@ -260,6 +260,7 @@ static void rhashtable_rehash_chain(struct rhashtable *ht, unsigned old_hash) spin_lock_bh(old_bucket_lock); while (!rhashtable_rehash_one(ht, old_hash)) ; + old_tbl->rehash++; spin_unlock_bh(old_bucket_lock); }
This patch adds a rehash counter to bucket_table to indicate the last bucket that has been rehashed. This serves two purposes: 1. Any bucket that has been rehashed can never gain a new object. 2. If the rehash counter reaches the size of the table, the table will forever remain empty. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> --- include/linux/rhashtable.h | 4 +++- lib/rhashtable.c | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html