X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=rculfhash.c;h=242a46702e1150c9d5c446c056c50daec243df41;hb=refs%2Fheads%2Fstable-0.8;hp=8a8ede7a6cadd1027a2c55c450ac3016f696fa6c;hpb=ab4b644ea95d7bd129d72cef888b01f940946e68;p=userspace-rcu.git diff --git a/rculfhash.c b/rculfhash.c index 8a8ede7..242a467 100644 --- a/rculfhash.c +++ b/rculfhash.c @@ -264,9 +264,10 @@ #include #include #include +#include #include "config.h" -#include +#include #include #include #include @@ -1176,6 +1177,10 @@ void partition_resize_helper(struct cds_lfht *ht, unsigned long i, int thread, ret; unsigned long nr_threads; + assert(nr_cpus_mask != -1); + if (nr_cpus_mask < 0 || len < 2 * MIN_PARTITION_PER_THREAD) + goto fallback; + /* * Note: nr_cpus_mask + 1 is always power of 2. * We spawn just the number of threads we need to satisfy the minimum @@ -1268,13 +1273,6 @@ static void init_table_populate(struct cds_lfht *ht, unsigned long i, unsigned long len) { - assert(nr_cpus_mask != -1); - if (nr_cpus_mask < 0 || len < 2 * MIN_PARTITION_PER_THREAD) { - ht->flavor->thread_online(); - init_table_populate_partition(ht, i, 0, len); - ht->flavor->thread_offline(); - return; - } partition_resize_helper(ht, i, len, init_table_populate_partition); } @@ -1367,14 +1365,6 @@ void remove_table_partition(struct cds_lfht *ht, unsigned long i, static void remove_table(struct cds_lfht *ht, unsigned long i, unsigned long len) { - - assert(nr_cpus_mask != -1); - if (nr_cpus_mask < 0 || len < 2 * MIN_PARTITION_PER_THREAD) { - ht->flavor->thread_online(); - remove_table_partition(ht, i, 0, len); - ht->flavor->thread_offline(); - return; - } partition_resize_helper(ht, i, len, remove_table_partition); } @@ -1397,7 +1387,7 @@ void fini_table(struct cds_lfht *ht, unsigned long len; len = 1UL << (i - 1); - dbg_printf("fini order %lu len: %lu\n", i, len); + dbg_printf("fini order %ld len: %lu\n", i, len); /* Stop shrink if the resize target changes under us */ if (CMM_LOAD_SHARED(ht->resize_target) > (1UL << (i - 1))) @@ -1816,6 +1806,9 @@ int cds_lfht_destroy(struct cds_lfht *ht, pthread_attr_t **attr) free_split_items_count(ht); if (attr) *attr = ht->resize_attr; + ret = pthread_mutex_destroy(&ht->resize_mutex); + if (ret) + ret = -EBUSY; poison_free(ht); end: return ret;