rculfhash: merge duplicated code of cds_lfht_resize_lazy_*()
authorLai Jiangshan <laijs@cn.fujitsu.com>
Wed, 2 Nov 2011 15:21:35 +0000 (11:21 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 2 Nov 2011 15:21:35 +0000 (11:21 -0400)
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
rculfhash.c

index d89c0cb6635ead96de12a9bdbb82d7c2b8e0a0b2..ce7197aa822b53510ca9fe58822e47563f11ccdf 100644 (file)
@@ -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);
 }
This page took 0.027164 seconds and 4 git commands to generate.