Skip to content

Commit

Permalink
rhashtable: Add comment on choice of elasticity value
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Herbert Xu authored and David S. Miller committed Mar 24, 2015
1 parent 8263d57 commit 27ed44a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/rhashtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,18 @@ int rhashtable_init(struct rhashtable *ht,

ht->p.min_size = max(ht->p.min_size, HASH_MIN_SIZE);

/* The maximum (not average) chain length grows with the
* size of the hash table, at a rate of (log N)/(log log N).
* The value of 16 is selected so that even if the hash
* table grew to 2^32 you would not expect the maximum
* chain length to exceed it unless we are under attack
* (or extremely unlucky).
*
* As this limit is only to detect attacks, we don't need
* to set it to a lower value as you'd need the chain
* length to vastly exceed 16 to have any real effect
* on the system.
*/
if (!params->insecure_elasticity)
ht->elasticity = 16;

Expand Down

0 comments on commit 27ed44a

Please sign in to comment.