From: Mathieu Desnoyers Date: Mon, 11 Jul 2011 21:56:21 +0000 (-0400) Subject: rculfhash test: make teardown more verbose and faster X-Git-Tag: v0.7.0~43^2~196 X-Git-Url: https://git.liburcu.org/?p=urcu.git;a=commitdiff_plain;h=33c7c748c098dfc963c934fde62328169834c1ed rculfhash test: make teardown more verbose and faster Signed-off-by: Mathieu Desnoyers --- diff --git a/rculfhash.c b/rculfhash.c index 7605036..f3c9688 100644 --- a/rculfhash.c +++ b/rculfhash.c @@ -76,7 +76,7 @@ struct rcu_ht { ht_compare_fct compare_fct; unsigned long hash_seed; pthread_mutex_t resize_mutex; /* resize mutex: add/del mutex */ - unsigned int in_progress_resize; + unsigned int in_progress_resize, in_progress_destroy; void (*ht_call_rcu)(struct rcu_head *head, void (*func)(struct rcu_head *head)); }; @@ -525,10 +525,14 @@ void init_table(struct rcu_ht *ht, struct rcu_table *t, new_node->p.reverse_hash = bit_reverse_ulong(!i ? 0 : (1UL << (i - 1)) + j); (void) _ht_add(ht, t, new_node, 0, 1); + if (CMM_LOAD_SHARED(ht->in_progress_destroy)) + break; } /* Update table size */ t->size = !i ? 1 : (1UL << i); dbg_printf("rculfhash: init new size: %lu\n", t->size); + if (CMM_LOAD_SHARED(ht->in_progress_destroy)) + break; } t->resize_target = t->size; t->resize_initiated = 0; @@ -673,6 +677,7 @@ int ht_destroy(struct rcu_ht *ht) int ret; /* Wait for in-flight resize operations to complete */ + CMM_STORE_SHARED(ht->in_progress_destroy, 1); while (uatomic_read(&ht->in_progress_resize)) poll(NULL, 0, 100); /* wait for 100ms */ ret = ht_delete_dummy(ht); diff --git a/tests/test_urcu_hash.c b/tests/test_urcu_hash.c index 0af6eeb..280000c 100644 --- a/tests/test_urcu_hash.c +++ b/tests/test_urcu_hash.c @@ -115,7 +115,7 @@ static int verbose_mode; #define printf_verbose(fmt, args...) \ do { \ if (verbose_mode) \ - printf(fmt, args); \ + printf(fmt, ## args); \ } while (0) static unsigned int cpu_affinities[NR_CPUS]; @@ -653,13 +653,19 @@ int main(int argc, char **argv) tot_add += count_writer[i].add; tot_remove += count_writer[i].remove; } + printf("Counting nodes... "); + fflush(stdout); ht_count_nodes(test_ht, &count, &removed); + printf("done.\n"); if (count || removed) printf("WARNING: nodes left in the hash table upon destroy: " "%lu nodes + %lu logically removed.\n", count, removed); - (void) ht_destroy(test_ht); + ret = ht_destroy(test_ht); - printf_verbose("final delete: %d items\n", ret); + if (ret) + printf_verbose("final delete aborted\n"); + else + printf_verbose("final delete success\n"); printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads, tot_writes); printf("SUMMARY %-25s testdur %4lu nr_readers %3u rdur %6lu "