rhashtable.c (3a37471551cd3b287ce7f02ed25bcf8ec37a191d) | rhashtable.c (5f8ddeab10ce45d3d3de8ae7ea8811512845c497) |
---|---|
1/* 2 * Resizable, Scalable, Concurrent Hash Table 3 * 4 * Copyright (c) 2015 Herbert Xu <herbert@gondor.apana.org.au> 5 * Copyright (c) 2014-2015 Thomas Graf <tgraf@suug.ch> 6 * Copyright (c) 2008-2014 Patrick McHardy <kaber@trash.net> 7 * 8 * Code partially derived from nft_hash --- 521 unchanged lines hidden (view full) --- 530 struct rhashtable_compare_arg arg = { 531 .ht = ht, 532 .key = key, 533 }; 534 struct rhash_head __rcu **pprev; 535 struct rhash_head *head; 536 int elasticity; 537 | 1/* 2 * Resizable, Scalable, Concurrent Hash Table 3 * 4 * Copyright (c) 2015 Herbert Xu <herbert@gondor.apana.org.au> 5 * Copyright (c) 2014-2015 Thomas Graf <tgraf@suug.ch> 6 * Copyright (c) 2008-2014 Patrick McHardy <kaber@trash.net> 7 * 8 * Code partially derived from nft_hash --- 521 unchanged lines hidden (view full) --- 530 struct rhashtable_compare_arg arg = { 531 .ht = ht, 532 .key = key, 533 }; 534 struct rhash_head __rcu **pprev; 535 struct rhash_head *head; 536 int elasticity; 537 |
538 elasticity = ht->elasticity; | 538 elasticity = RHT_ELASTICITY; |
539 pprev = rht_bucket_var(tbl, hash); 540 rht_for_each_continue(head, *pprev, tbl, hash) { 541 struct rhlist_head *list; 542 struct rhlist_head *plist; 543 544 elasticity--; 545 if (!key || 546 (ht->p.obj_cmpfn ? --- 420 unchanged lines hidden (view full) --- 967 else 968 ht->p.insecure_max_entries = ht->p.max_size * 2; 969 970 ht->p.min_size = max(ht->p.min_size, HASH_MIN_SIZE); 971 972 if (params->nelem_hint) 973 size = rounded_hashtable_size(&ht->p); 974 | 539 pprev = rht_bucket_var(tbl, hash); 540 rht_for_each_continue(head, *pprev, tbl, hash) { 541 struct rhlist_head *list; 542 struct rhlist_head *plist; 543 544 elasticity--; 545 if (!key || 546 (ht->p.obj_cmpfn ? --- 420 unchanged lines hidden (view full) --- 967 else 968 ht->p.insecure_max_entries = ht->p.max_size * 2; 969 970 ht->p.min_size = max(ht->p.min_size, HASH_MIN_SIZE); 971 972 if (params->nelem_hint) 973 size = rounded_hashtable_size(&ht->p); 974 |
975 /* The maximum (not average) chain length grows with the 976 * size of the hash table, at a rate of (log N)/(log log N). 977 * The value of 16 is selected so that even if the hash 978 * table grew to 2^32 you would not expect the maximum 979 * chain length to exceed it unless we are under attack 980 * (or extremely unlucky). 981 * 982 * As this limit is only to detect attacks, we don't need 983 * to set it to a lower value as you'd need the chain 984 * length to vastly exceed 16 to have any real effect 985 * on the system. 986 */ 987 if (!params->insecure_elasticity) 988 ht->elasticity = 16; 989 | |
990 if (params->locks_mul) 991 ht->p.locks_mul = roundup_pow_of_two(params->locks_mul); 992 else 993 ht->p.locks_mul = BUCKET_LOCKS_PER_CPU; 994 995 ht->key_len = ht->p.key_len; 996 if (!params->hashfn) { 997 ht->p.hashfn = jhash; --- 182 unchanged lines hidden --- | 975 if (params->locks_mul) 976 ht->p.locks_mul = roundup_pow_of_two(params->locks_mul); 977 else 978 ht->p.locks_mul = BUCKET_LOCKS_PER_CPU; 979 980 ht->key_len = ht->p.key_len; 981 if (!params->hashfn) { 982 ht->p.hashfn = jhash; --- 182 unchanged lines hidden --- |