Fix gc tests
authorMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Thu, 18 Jun 2009 15:01:18 +0000 (11:01 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Thu, 18 Jun 2009 15:01:18 +0000 (11:01 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
test_qsbr_gc.c
test_urcu_gc.c

index 0b34ecec11e035385a6af45a968526483c564f09..c5cb9b168a905206d9bd837c9e9edc471d456dbd 100644 (file)
@@ -180,20 +180,11 @@ void *thr_reader(void *_count)
 
 }
 
-/* Using per-thread queue */
-static void rcu_gc_reclaim(unsigned long wtidx, void *old)
+static void rcu_gc_clear_queue(unsigned long wtidx)
 {
        void **p;
 
-       /* Queue pointer */
-       *pending_reclaims[wtidx].head = old;
-       pending_reclaims[wtidx].head++;
-
-       if (likely(pending_reclaims[wtidx].head - pending_reclaims[wtidx].queue
-                       < reclaim_batch))
-               return;
-
-       /* If queue is full, wait for Q.S and empty queue */
+       /* Wait for Q.S and empty queue */
        synchronize_rcu();
 
        for (p = pending_reclaims[wtidx].queue;
@@ -206,21 +197,18 @@ static void rcu_gc_reclaim(unsigned long wtidx, void *old)
        pending_reclaims[wtidx].head = pending_reclaims[wtidx].queue;
 }
 
-static void rcu_gc_cleanup(unsigned long wtidx)
+/* Using per-thread queue */
+static void rcu_gc_reclaim(unsigned long wtidx, void *old)
 {
-       void **p;
+       /* Queue pointer */
+       *pending_reclaims[wtidx].head = old;
+       pending_reclaims[wtidx].head++;
 
-       /* Wait for Q.S and empty queue */
-       synchronize_rcu();
+       if (likely(pending_reclaims[wtidx].head - pending_reclaims[wtidx].queue
+                       < reclaim_batch))
+               return;
 
-       for (p = pending_reclaims[wtidx].queue;
-                       p < pending_reclaims[wtidx].head; p++) {
-               /* poison */
-               if (*p)
-                       ((struct test_array *)*p)->a = 0;
-               free(*p);
-       }
-       pending_reclaims[wtidx].head = pending_reclaims[wtidx].queue;
+       rcu_gc_clear_queue(wtidx);
 }
 
 void *thr_writer(void *data)
@@ -419,7 +407,7 @@ int main(int argc, char **argv)
                if (err != 0)
                        exit(1);
                tot_writes += tot_nr_writes[i];
-               rcu_gc_cleanup(i);
+               rcu_gc_clear_queue(i);
        }
        
        printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads,
index d8dc70952817f61ceb13ab1cb0ec6b737c4ba02e..ee936f04d7633dd39d6316d7f9d21c1012f4490d 100644 (file)
@@ -181,20 +181,11 @@ void *thr_reader(void *_count)
 
 }
 
-/* Using per-thread queue */
-static void rcu_gc_reclaim(unsigned long wtidx, void *old)
+static void rcu_gc_clear_queue(unsigned long wtidx)
 {
        void **p;
 
-       /* Queue pointer */
-       *pending_reclaims[wtidx].head = old;
-       pending_reclaims[wtidx].head++;
-
-       if (likely(pending_reclaims[wtidx].head - pending_reclaims[wtidx].queue
-                       < reclaim_batch))
-               return;
-
-       /* If queue is full, wait for Q.S and empty queue */
+       /* Wait for Q.S and empty queue */
        synchronize_rcu();
 
        for (p = pending_reclaims[wtidx].queue;
@@ -207,21 +198,18 @@ static void rcu_gc_reclaim(unsigned long wtidx, void *old)
        pending_reclaims[wtidx].head = pending_reclaims[wtidx].queue;
 }
 
-static void rcu_gc_cleanup(unsigned long wtidx)
+/* Using per-thread queue */
+static void rcu_gc_reclaim(unsigned long wtidx, void *old)
 {
-       void **p;
+       /* Queue pointer */
+       *pending_reclaims[wtidx].head = old;
+       pending_reclaims[wtidx].head++;
 
-       /* Wait for Q.S and empty queue */
-       synchronize_rcu();
+       if (likely(pending_reclaims[wtidx].head - pending_reclaims[wtidx].queue
+                       < reclaim_batch))
+               return;
 
-       for (p = pending_reclaims[wtidx].queue;
-                       p < pending_reclaims[wtidx].head; p++) {
-               /* poison */
-               if (*p)
-                       ((struct test_array *)*p)->a = 0;
-               free(*p);
-       }
-       pending_reclaims[wtidx].head = pending_reclaims[wtidx].queue;
+       rcu_gc_clear_queue(wtidx);
 }
 
 void *thr_writer(void *data)
@@ -420,7 +408,7 @@ int main(int argc, char **argv)
                if (err != 0)
                        exit(1);
                tot_writes += tot_nr_writes[i];
-               rcu_gc_cleanup(i);
+               rcu_gc_clear_queue(i);
        }
        
        printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads,
This page took 0.037127 seconds and 4 git commands to generate.