From: Lai Jiangshan Date: Wed, 2 Nov 2011 15:21:35 +0000 (-0400) Subject: rculfhash: merge duplicated code of cds_lfht_resize_lazy_*() X-Git-Tag: v0.7.0~43^2~62 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=f1f119ee8b4859cff4bbe8c5e1b6b241d5c13a8b;p=urcu.git rculfhash: merge duplicated code of cds_lfht_resize_lazy_*() Signed-off-by: Lai Jiangshan Signed-off-by: Mathieu Desnoyers --- diff --git a/rculfhash.c b/rculfhash.c index d89c0cb..ce7197a 100644 --- a/rculfhash.c +++ b/rculfhash.c @@ -1796,13 +1796,9 @@ void do_resize_cb(struct rcu_head *head) } static -void cds_lfht_resize_lazy_grow(struct cds_lfht *ht, unsigned long size, int growth) +void __cds_lfht_resize_lazy_launch(struct cds_lfht *ht) { struct rcu_resize_work *work; - unsigned long target_size = size << growth; - - if (resize_target_grow(ht, target_size) >= target_size) - return; /* Store resize_target before read resize_initiated */ cmm_smp_mb(); @@ -1820,27 +1816,24 @@ void cds_lfht_resize_lazy_grow(struct cds_lfht *ht, unsigned long size, int grow } } +static +void cds_lfht_resize_lazy_grow(struct cds_lfht *ht, unsigned long size, int growth) +{ + unsigned long target_size = size << growth; + + if (resize_target_grow(ht, target_size) >= target_size) + return; + + __cds_lfht_resize_lazy_launch(ht); +} + static void cds_lfht_resize_lazy_count(struct cds_lfht *ht, unsigned long size, unsigned long count) { - struct rcu_resize_work *work; - if (!(ht->flags & CDS_LFHT_AUTO_RESIZE)) return; + resize_target_update_count(ht, count); - /* Store resize_target before read resize_initiated */ - cmm_smp_mb(); - if (!CMM_LOAD_SHARED(ht->t.resize_initiated)) { - uatomic_inc(&ht->in_progress_resize); - cmm_smp_mb(); /* increment resize count before load destroy */ - if (CMM_LOAD_SHARED(ht->in_progress_destroy)) { - uatomic_dec(&ht->in_progress_resize); - return; - } - work = malloc(sizeof(*work)); - work->ht = ht; - ht->cds_lfht_call_rcu(&work->head, do_resize_cb); - CMM_STORE_SHARED(ht->t.resize_initiated, 1); - } + __cds_lfht_resize_lazy_launch(ht); }