diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2015-03-23 22:37:30 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-03-24 14:57:04 -0400 |
commit | 27ed44a5d6d88897002b75f53004d4c565a5aab6 (patch) | |
tree | 6e1ddb2743ca32a240661bd395160437280d2d03 /lib/rhashtable.c | |
parent | 8263d57e376546bd5da42ea377d22c43239aa317 (diff) |
rhashtable: Add comment on choice of elasticity value
This patch adds a comment on the choice of the value 16 as the
maximum chain length before we force a rehash.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'lib/rhashtable.c')
-rw-r--r-- | lib/rhashtable.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/rhashtable.c b/lib/rhashtable.c index e96ad1a52c90..8514f7c5f029 100644 --- a/lib/rhashtable.c +++ b/lib/rhashtable.c | |||
@@ -736,6 +736,18 @@ int rhashtable_init(struct rhashtable *ht, | |||
736 | 736 | ||
737 | ht->p.min_size = max(ht->p.min_size, HASH_MIN_SIZE); | 737 | ht->p.min_size = max(ht->p.min_size, HASH_MIN_SIZE); |
738 | 738 | ||
739 | /* The maximum (not average) chain length grows with the | ||
740 | * size of the hash table, at a rate of (log N)/(log log N). | ||
741 | * The value of 16 is selected so that even if the hash | ||
742 | * table grew to 2^32 you would not expect the maximum | ||
743 | * chain length to exceed it unless we are under attack | ||
744 | * (or extremely unlucky). | ||
745 | * | ||
746 | * As this limit is only to detect attacks, we don't need | ||
747 | * to set it to a lower value as you'd need the chain | ||
748 | * length to vastly exceed 16 to have any real effect | ||
749 | * on the system. | ||
750 | */ | ||
739 | if (!params->insecure_elasticity) | 751 | if (!params->insecure_elasticity) |
740 | ht->elasticity = 16; | 752 | ht->elasticity = 16; |
741 | 753 | ||