mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-29 23:24:11 +08:00
rhashtable: Disable automatic shrinking by default
Introduce a new bool automatic_shrinking to require the user to explicitly opt-in to automatic shrinking of tables. Signed-off-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
ac833bddb5
commit
b5e2c150ac
@ -2,7 +2,7 @@
|
|||||||
* Resizable, Scalable, Concurrent Hash Table
|
* Resizable, Scalable, Concurrent Hash Table
|
||||||
*
|
*
|
||||||
* Copyright (c) 2015 Herbert Xu <herbert@gondor.apana.org.au>
|
* Copyright (c) 2015 Herbert Xu <herbert@gondor.apana.org.au>
|
||||||
* Copyright (c) 2014 Thomas Graf <tgraf@suug.ch>
|
* Copyright (c) 2014-2015 Thomas Graf <tgraf@suug.ch>
|
||||||
* Copyright (c) 2008-2014 Patrick McHardy <kaber@trash.net>
|
* Copyright (c) 2008-2014 Patrick McHardy <kaber@trash.net>
|
||||||
*
|
*
|
||||||
* Code partially derived from nft_hash
|
* Code partially derived from nft_hash
|
||||||
@ -104,6 +104,7 @@ struct rhashtable;
|
|||||||
* @min_size: Minimum size while shrinking
|
* @min_size: Minimum size while shrinking
|
||||||
* @nulls_base: Base value to generate nulls marker
|
* @nulls_base: Base value to generate nulls marker
|
||||||
* @insecure_elasticity: Set to true to disable chain length checks
|
* @insecure_elasticity: Set to true to disable chain length checks
|
||||||
|
* @automatic_shrinking: Enable automatic shrinking of tables
|
||||||
* @locks_mul: Number of bucket locks to allocate per cpu (default: 128)
|
* @locks_mul: Number of bucket locks to allocate per cpu (default: 128)
|
||||||
* @hashfn: Hash function (default: jhash2 if !(key_len % 4), or jhash)
|
* @hashfn: Hash function (default: jhash2 if !(key_len % 4), or jhash)
|
||||||
* @obj_hashfn: Function to hash object
|
* @obj_hashfn: Function to hash object
|
||||||
@ -118,6 +119,7 @@ struct rhashtable_params {
|
|||||||
unsigned int min_size;
|
unsigned int min_size;
|
||||||
u32 nulls_base;
|
u32 nulls_base;
|
||||||
bool insecure_elasticity;
|
bool insecure_elasticity;
|
||||||
|
bool automatic_shrinking;
|
||||||
size_t locks_mul;
|
size_t locks_mul;
|
||||||
rht_hashfn_t hashfn;
|
rht_hashfn_t hashfn;
|
||||||
rht_obj_hashfn_t obj_hashfn;
|
rht_obj_hashfn_t obj_hashfn;
|
||||||
@ -784,7 +786,8 @@ static inline int rhashtable_remove_fast(
|
|||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
atomic_dec(&ht->nelems);
|
atomic_dec(&ht->nelems);
|
||||||
if (rht_shrink_below_30(ht, tbl))
|
if (unlikely(ht->p.automatic_shrinking &&
|
||||||
|
rht_shrink_below_30(ht, tbl)))
|
||||||
schedule_work(&ht->run_work);
|
schedule_work(&ht->run_work);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
@ -367,7 +367,7 @@ static void rht_deferred_worker(struct work_struct *work)
|
|||||||
|
|
||||||
if (rht_grow_above_75(ht, tbl))
|
if (rht_grow_above_75(ht, tbl))
|
||||||
rhashtable_expand(ht);
|
rhashtable_expand(ht);
|
||||||
else if (rht_shrink_below_30(ht, tbl))
|
else if (ht->p.automatic_shrinking && rht_shrink_below_30(ht, tbl))
|
||||||
rhashtable_shrink(ht);
|
rhashtable_shrink(ht);
|
||||||
|
|
||||||
err = rhashtable_rehash_table(ht);
|
err = rhashtable_rehash_table(ht);
|
||||||
|
@ -172,6 +172,7 @@ static const struct rhashtable_params nft_hash_params = {
|
|||||||
.head_offset = offsetof(struct nft_hash_elem, node),
|
.head_offset = offsetof(struct nft_hash_elem, node),
|
||||||
.key_offset = offsetof(struct nft_hash_elem, key),
|
.key_offset = offsetof(struct nft_hash_elem, key),
|
||||||
.hashfn = jhash,
|
.hashfn = jhash,
|
||||||
|
.automatic_shrinking = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int nft_hash_init(const struct nft_set *set,
|
static int nft_hash_init(const struct nft_set *set,
|
||||||
|
@ -3142,6 +3142,7 @@ static const struct rhashtable_params netlink_rhashtable_params = {
|
|||||||
.obj_hashfn = netlink_hash,
|
.obj_hashfn = netlink_hash,
|
||||||
.obj_cmpfn = netlink_compare,
|
.obj_cmpfn = netlink_compare,
|
||||||
.max_size = 65536,
|
.max_size = 65536,
|
||||||
|
.automatic_shrinking = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int __init netlink_proto_init(void)
|
static int __init netlink_proto_init(void)
|
||||||
|
@ -2297,6 +2297,7 @@ static const struct rhashtable_params tsk_rht_params = {
|
|||||||
.key_len = sizeof(u32), /* portid */
|
.key_len = sizeof(u32), /* portid */
|
||||||
.max_size = 1048576,
|
.max_size = 1048576,
|
||||||
.min_size = 256,
|
.min_size = 256,
|
||||||
|
.automatic_shrinking = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
int tipc_sk_rht_init(struct net *net)
|
int tipc_sk_rht_init(struct net *net)
|
||||||
|
Loading…
Reference in New Issue
Block a user