X-Git-Url: https://git.lttng.org/?p=urcu.git;a=blobdiff_plain;f=rculfhash.c;h=d04451fece7ac744cb0b894b1f2b5e3803b9785f;hp=6c648f17da8a939d22894067eb1cc8c24620a8e0;hb=5a2141a73185fb1aaaceb73f8239a7efb81c16e6;hpb=b69e8b3f8cec89492c706cb6a3c0e1f85dccfcfd diff --git a/rculfhash.c b/rculfhash.c index 6c648f1..d04451f 100644 --- a/rculfhash.c +++ b/rculfhash.c @@ -1271,6 +1271,30 @@ struct cds_lfht *_cds_lfht_new(unsigned long init_size, if (!init_size || (init_size & (init_size - 1))) return NULL; + /* + * Memory management plugin default. + */ + if (!mm) { + if (CAA_BITS_PER_LONG > 32 + && max_nr_buckets + && max_nr_buckets <= (1ULL << 32)) { + /* + * For 64-bit architectures, with max number of + * buckets small enough not to use the entire + * 64-bit memory mapping space (and allowing a + * fair number of hash table instances), use the + * mmap allocator, which is faster than the + * order allocator. + */ + mm = &cds_lfht_mm_mmap; + } else { + /* + * The fallback is to use the order allocator. + */ + mm = &cds_lfht_mm_order; + } + } + /* max_nr_buckets == 0 for order based mm means infinite */ if (mm == &cds_lfht_mm_order && !max_nr_buckets) max_nr_buckets = 1UL << (MAX_TABLE_ORDER - 1);