X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=rculfhash.c;h=5ef2c781e3f6330ca631910df85f0a8ef92de954;hb=c1888f3a47cf8f7c213269888ce42d191de7e34a;hp=8c835dedb71c733cca89872ff685e254c5297a23;hpb=61adb3377baa87703f7d1b50ec5b576258f74ba8;p=urcu.git diff --git a/rculfhash.c b/rculfhash.c index 8c835de..5ef2c78 100644 --- a/rculfhash.c +++ b/rculfhash.c @@ -242,15 +242,6 @@ struct partition_resize_work { unsigned long start, unsigned long len); }; -static -void _cds_lfht_add(struct cds_lfht *ht, - cds_lfht_match_fct match, - const void *key, - unsigned long size, - struct cds_lfht_node *node, - struct cds_lfht_iter *unique_ret, - int bucket); - /* * Algorithm to reverse bits in a word by lookup table, extended to * 64-bit words. @@ -1280,6 +1271,36 @@ 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 (!max_nr_buckets) { + /* + * If the maximum number of buckets is not + * specified, we cannot use the mmap allocator, + * so fallback on order allocator. + */ + mm = &cds_lfht_mm_order; + } else if (CAA_BITS_PER_LONG > 32 + && 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);