The patch titled Subject: lib/rhashtable: consider param->min_size when setting initial table size has been added to the -mm tree. Its filename is lib-rhashtable-consider-param-min_size-when-setting-initial-table-size.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/lib-rhashtable-consider-param-min_size-when-setting-initial-table-size.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/lib-rhashtable-consider-param-min_size-when-setting-initial-table-size.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Davidlohr Bueso <dave@xxxxxxxxxxxx> Subject: lib/rhashtable: consider param->min_size when setting initial table size rhashtable_init() currently does not take into account the user-passed min_size parameter unless param->nelem_hint is set as well. As such, the default size (number of buckets) will always be HASH_DEFAULT_SIZE even if the smallest allowed size is larger than that. Remediate this by unconditionally calling into rounded_hashtable_size() and handling things accordingly. Link: http://lkml.kernel.org/r/20180716202613.u6f3l3adrgjvs4wk@linux-r8p5 Signed-off-by: Davidlohr Bueso <dbueso@xxxxxxx> Acked-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> Reviewed-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- diff -puN lib/rhashtable.c~lib-rhashtable-consider-param-min_size-when-setting-initial-table-size lib/rhashtable.c --- a/lib/rhashtable.c~lib-rhashtable-consider-param-min_size-when-setting-initial-table-size +++ a/lib/rhashtable.c @@ -964,8 +964,16 @@ EXPORT_SYMBOL_GPL(rhashtable_walk_stop); static size_t rounded_hashtable_size(const struct rhashtable_params *params) { - return max(roundup_pow_of_two(params->nelem_hint * 4 / 3), - (unsigned long)params->min_size); + size_t retsize; + + if (params->nelem_hint) + retsize = max(roundup_pow_of_two(params->nelem_hint * 4 / 3), + (unsigned long)params->min_size); + else + retsize = max(HASH_DEFAULT_SIZE, + (unsigned long)params->min_size); + + return retsize; } static u32 rhashtable_jhash2(const void *key, u32 length, u32 seed) @@ -1022,8 +1030,6 @@ int rhashtable_init(struct rhashtable *h struct bucket_table *tbl; size_t size; - size = HASH_DEFAULT_SIZE; - if ((!params->key_len && !params->obj_hashfn) || (params->obj_hashfn && !params->obj_cmpfn)) return -EINVAL; @@ -1050,8 +1056,7 @@ int rhashtable_init(struct rhashtable *h ht->p.min_size = max_t(u16, ht->p.min_size, HASH_MIN_SIZE); - if (params->nelem_hint) - size = rounded_hashtable_size(&ht->p); + size = rounded_hashtable_size(&ht->p); if (params->locks_mul) ht->p.locks_mul = roundup_pow_of_two(params->locks_mul); _ Patches currently in -mm which might be from dave@xxxxxxxxxxxx are ipc-sem-prevent-queuestatus-tearing-in-semop.patch ipc-drop-ipc_lock.patch lib-rhashtable-simplify-bucket_table_alloc.patch lib-rhashtable-guarantee-initial-hashtable-allocation.patch ipc-get-rid-of-ids-tables_initialized-hack.patch ipc-simplify-ipc-initialization.patch lib-rhashtable-consider-param-min_size-when-setting-initial-table-size.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html