rhashtable: remove insecure_max_entries param
authorFlorian Westphal <fw@strlen.de>
Tue, 25 Apr 2017 09:41:34 +0000 (11:41 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 26 Apr 2017 18:39:24 +0000 (14:39 -0400)
no users in the tree, insecure_max_entries is always set to
ht->p.max_size * 2 in rhtashtable_init().

Replace only spot that uses it with a ht->p.max_size check.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/rhashtable.h
lib/rhashtable.c

index ae87dcdf52d297795c2949a5493eae55d367e74f..ae93b65d13d70bdc78e56f54006a9cd43822cd42 100644 (file)
@@ -125,7 +125,6 @@ struct rhashtable;
  * @key_len: Length of key
  * @key_offset: Offset of key in struct to be hashed
  * @head_offset: Offset of rhash_head in struct to be hashed
- * @insecure_max_entries: Maximum number of entries (may be exceeded)
  * @max_size: Maximum size while expanding
  * @min_size: Minimum size while shrinking
  * @nulls_base: Base value to generate nulls marker
@@ -140,7 +139,6 @@ struct rhashtable_params {
        size_t                  key_len;
        size_t                  key_offset;
        size_t                  head_offset;
-       unsigned int            insecure_max_entries;
        unsigned int            max_size;
        unsigned int            min_size;
        u32                     nulls_base;
@@ -329,8 +327,8 @@ static inline bool rht_grow_above_100(const struct rhashtable *ht,
 static inline bool rht_grow_above_max(const struct rhashtable *ht,
                                      const struct bucket_table *tbl)
 {
-       return ht->p.insecure_max_entries &&
-              atomic_read(&ht->nelems) >= ht->p.insecure_max_entries;
+       return ht->p.max_size &&
+              (atomic_read(&ht->nelems) / 2u) >= ht->p.max_size;
 }
 
 /* The bucket lock is selected based on the hash and protects mutations
index d22a5ef109fb8c52db8b24c322536ebb38be6738..f3b82e0d417b360e24d92b943f47547327b1e5ef 100644 (file)
@@ -961,12 +961,6 @@ int rhashtable_init(struct rhashtable *ht,
        if (params->max_size)
                ht->p.max_size = rounddown_pow_of_two(params->max_size);
 
-       if (params->insecure_max_entries)
-               ht->p.insecure_max_entries =
-                       rounddown_pow_of_two(params->insecure_max_entries);
-       else
-               ht->p.insecure_max_entries = ht->p.max_size * 2;
-
        ht->p.min_size = max(ht->p.min_size, HASH_MIN_SIZE);
 
        if (params->nelem_hint)