X-Git-Url: https://git.lttng.org/?p=urcu.git;a=blobdiff_plain;f=test_urcu_gc.c;h=ee936f04d7633dd39d6316d7f9d21c1012f4490d;hp=328b570fa4d2e5219e1adb5afb644c4fb3a827ad;hb=c97ae6eb5bf6baea503d9df98e8376c0bd36b629;hpb=a813abf8d937798b4a1b6e3246e844d75eef5756 diff --git a/test_urcu_gc.c b/test_urcu_gc.c index 328b570..ee936f0 100644 --- a/test_urcu_gc.c +++ b/test_urcu_gc.c @@ -70,7 +70,7 @@ static unsigned long wdelay; static struct test_array *test_rcu_pointer; -static int reclaim_batch = 1; +static unsigned int reclaim_batch = 1; struct reclaim_queue { void **queue; /* Beginning of queue */ @@ -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,17 +408,18 @@ 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, tot_writes); printf("SUMMARY %-25s testdur %4lu nr_readers %3u rdur %6lu " "nr_writers %3u " - "wdelay %6lu nr_reads %12llu nr_writes %12llu nr_ops %12llu\n", + "wdelay %6lu nr_reads %12llu nr_writes %12llu nr_ops %12llu " + "batch %u\n", argv[0], duration, nr_readers, rduration, nr_writers, wdelay, tot_reads, tot_writes, - tot_reads + tot_writes); + tot_reads + tot_writes, reclaim_batch); free(tid_reader); free(tid_writer); free(count_reader);