Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rhashtable: Restore insecure_elasticity toggle

Some users of rhashtable cannot handle insertion failures, and
are happy to accept the consequences of a hash table that having
very long chains.

Restore the insecure_elasticity toggle for these users. In
addition to disabling the chain length checks, this also removes
the emergency resize that would otherwise occur when the hash
table occupancy hits 100% (an async resize is still scheduled
at 75%).

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Tejun Heo <tj@kernel.org>

authored by

Herbert Xu and committed by
Tejun Heo
73bd1227 3cd8b194

+8 -4
+2
include/linux/rhashtable-types.h
··· 49 49 * @head_offset: Offset of rhash_head in struct to be hashed 50 50 * @max_size: Maximum size while expanding 51 51 * @min_size: Minimum size while shrinking 52 + * @insecure_elasticity: Set to true to disable chain length checks 52 53 * @automatic_shrinking: Enable automatic shrinking of tables 53 54 * @hashfn: Hash function (default: jhash2 if !(key_len % 4), or jhash) 54 55 * @obj_hashfn: Function to hash object ··· 62 61 u16 head_offset; 63 62 unsigned int max_size; 64 63 u16 min_size; 64 + bool insecure_elasticity; 65 65 bool automatic_shrinking; 66 66 rht_hashfn_t hashfn; 67 67 rht_obj_hashfn_t obj_hashfn;
+3 -2
include/linux/rhashtable.h
··· 821 821 goto out; 822 822 } 823 823 824 - if (elasticity <= 0) 824 + if (elasticity <= 0 && !params.insecure_elasticity) 825 825 goto slow_path; 826 826 827 827 data = ERR_PTR(-E2BIG); 828 828 if (unlikely(rht_grow_above_max(ht, tbl))) 829 829 goto out_unlock; 830 830 831 - if (unlikely(rht_grow_above_100(ht, tbl))) 831 + if (unlikely(rht_grow_above_100(ht, tbl)) && 832 + !params.insecure_elasticity) 832 833 goto slow_path; 833 834 834 835 /* Inserting at head of list makes unlocking free. */
+3 -2
lib/rhashtable.c
··· 538 538 return NULL; 539 539 } 540 540 541 - if (elasticity <= 0) 541 + if (elasticity <= 0 && !ht->p.insecure_elasticity) 542 542 return ERR_PTR(-EAGAIN); 543 543 544 544 return ERR_PTR(-ENOENT); ··· 568 568 if (unlikely(rht_grow_above_max(ht, tbl))) 569 569 return ERR_PTR(-E2BIG); 570 570 571 - if (unlikely(rht_grow_above_100(ht, tbl))) 571 + if (unlikely(rht_grow_above_100(ht, tbl)) && 572 + !ht->p.insecure_elasticity) 572 573 return ERR_PTR(-EAGAIN); 573 574 574 575 head = rht_ptr(bkt, tbl, hash);