From: Mathieu Desnoyers Date: Sun, 14 Feb 2010 13:43:05 +0000 (-0500) Subject: urcu tests: add writer duration parameter X-Git-Tag: v0.4.2~27 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=31b598e0bb2fde285afa63986613e632e98b104d;p=urcu.git urcu tests: add writer duration parameter Signed-off-by: Mathieu Desnoyers --- diff --git a/tests/runtests.sh b/tests/runtests.sh index 981aef1..4b5f745 100755 --- a/tests/runtests.sh +++ b/tests/runtests.sh @@ -1,9 +1,9 @@ #!/bin/sh -for a in test_urcu_gc test_urcu_gc_mb test_urcu test_urcu_mb \ - test_urcu_lgc test_qsbr_lgc test_urcu_lgc_mb \ - test_qsbr test_qsbr_gc test_rwlock test_perthreadlock \ - test_mutex; do +for a in test_urcu_gc test_urcu_signal_gc test_urcu_mb_gc test_qsbr_gc \ + test_urcu_lgc test_urcu_signal_lgc test_urcu_mb_lgc test_qsbr_lgc \ + test_urcu test_urcu_signal test_urcu_mb test_qsbr \ + test_rwlock test_perthreadlock test_mutex; do echo "./${a} $*" | tee -a runall.detail.log /usr/bin/time --append --output runall.detail.log ./${a} $* done diff --git a/tests/test_mutex.c b/tests/test_mutex.c index 7fb036d..f3139cc 100644 --- a/tests/test_mutex.c +++ b/tests/test_mutex.c @@ -79,6 +79,9 @@ static unsigned long duration; /* read-side C.S. duration, in loops */ static unsigned long rduration; +/* write-side C.S. duration, in loops */ +static unsigned long wduration; + static inline void loop_sleep(unsigned long l) { while(l-- != 0) @@ -232,6 +235,8 @@ void *thr_writer(void *data) pthread_mutex_lock(&lock); test_array.a = 0; test_array.a = 8; + if (unlikely(wduration)) + loop_sleep(wduration); pthread_mutex_unlock(&lock); nr_writes++; if (unlikely(!test_duration_write())) @@ -254,6 +259,7 @@ void show_usage(int argc, char **argv) #endif printf(" [-d delay] (writer period (us))"); printf(" [-c duration] (reader C.S. duration (in loops))"); + printf(" [-e duration] (writer C.S. duration (in loops))"); printf(" [-v] (verbose output)"); printf(" [-a cpu#] [-a cpu#]... (affinity)"); printf("\n"); @@ -328,6 +334,13 @@ int main(int argc, char **argv) } wdelay = atol(argv[++i]); break; + case 'e': + if (argc < i + 2) { + show_usage(argc, argv); + return -1; + } + wduration = atol(argv[++i]); + break; case 'v': verbose_mode = 1; break; diff --git a/tests/test_perthreadlock.c b/tests/test_perthreadlock.c index e47315b..7fcf3e8 100644 --- a/tests/test_perthreadlock.c +++ b/tests/test_perthreadlock.c @@ -83,6 +83,9 @@ static unsigned long duration; /* read-side C.S. duration, in loops */ static unsigned long rduration; +/* write-side C.S. duration, in loops */ +static unsigned long wduration; + static inline void loop_sleep(unsigned long l) { while(l-- != 0) @@ -239,6 +242,8 @@ void *thr_writer(void *data) } test_array.a = 0; test_array.a = 8; + if (unlikely(wduration)) + loop_sleep(wduration); for (tidx = (long)nr_readers - 1; tidx >= 0; tidx--) { pthread_mutex_unlock(&per_thread_lock[tidx].lock); } @@ -263,6 +268,7 @@ void show_usage(int argc, char **argv) #endif printf(" [-d delay] (writer period (us))"); printf(" [-c duration] (reader C.S. duration (in loops))"); + printf(" [-e duration] (writer C.S. duration (in loops))"); printf(" [-v] (verbose output)"); printf(" [-a cpu#] [-a cpu#]... (affinity)"); printf("\n"); @@ -337,6 +343,13 @@ int main(int argc, char **argv) } wdelay = atol(argv[++i]); break; + case 'e': + if (argc < i + 2) { + show_usage(argc, argv); + return -1; + } + wduration = atol(argv[++i]); + break; case 'v': verbose_mode = 1; break; diff --git a/tests/test_qsbr.c b/tests/test_qsbr.c index 7a68ae8..7c78b79 100644 --- a/tests/test_qsbr.c +++ b/tests/test_qsbr.c @@ -77,6 +77,9 @@ static unsigned long duration; /* read-side C.S. duration, in loops */ static unsigned long rduration; +/* write-side C.S. duration, in loops */ +static unsigned long wduration; + static inline void loop_sleep(unsigned long l) { while(l-- != 0) @@ -274,6 +277,8 @@ void *thr_writer(void *_count) new = test_array_alloc(); new->a = 8; old = rcu_xchg_pointer(&test_rcu_pointer, new); + if (unlikely(wduration)) + loop_sleep(wduration); synchronize_rcu(); /* can be done after unlock */ if (old) @@ -300,6 +305,7 @@ void show_usage(int argc, char **argv) #endif printf(" [-d delay] (writer period (us))"); printf(" [-c duration] (reader C.S. duration (in loops))"); + printf(" [-e duration] (writer C.S. duration (in loops))"); printf(" [-v] (verbose output)"); printf(" [-a cpu#] [-a cpu#]... (affinity)"); printf("\n"); @@ -373,6 +379,13 @@ int main(int argc, char **argv) } wdelay = atol(argv[++i]); break; + case 'e': + if (argc < i + 2) { + show_usage(argc, argv); + return -1; + } + wduration = atol(argv[++i]); + break; case 'v': verbose_mode = 1; break; diff --git a/tests/test_qsbr_gc.c b/tests/test_qsbr_gc.c index c480461..dd7a5c4 100644 --- a/tests/test_qsbr_gc.c +++ b/tests/test_qsbr_gc.c @@ -82,6 +82,9 @@ struct reclaim_queue { static struct reclaim_queue *pending_reclaims; +/* write-side C.S. duration, in loops */ +static unsigned long wduration; + static inline void loop_sleep(unsigned long l) { while(l-- != 0) @@ -284,6 +287,8 @@ void *thr_writer(void *data) new->a = 8; old = _rcu_xchg_pointer(&test_rcu_pointer, new); #endif + if (unlikely(wduration)) + loop_sleep(wduration); rcu_gc_reclaim(wtidx, old); nr_writes++; if (unlikely(!test_duration_write())) @@ -304,8 +309,10 @@ void show_usage(int argc, char **argv) #ifdef DEBUG_YIELD printf(" [-r] [-w] (yield reader and/or writer)"); #endif + printf(" [-b batch] (batch reclaim)"); printf(" [-d delay] (writer period (us))"); printf(" [-c duration] (reader C.S. duration (in loops))"); + printf(" [-e duration] (writer C.S. duration (in loops))"); printf(" [-v] (verbose output)"); printf(" [-a cpu#] [-a cpu#]... (affinity)"); printf("\n"); @@ -386,6 +393,13 @@ int main(int argc, char **argv) } wdelay = atol(argv[++i]); break; + case 'e': + if (argc < i + 2) { + show_usage(argc, argv); + return -1; + } + wduration = atol(argv[++i]); + break; case 'v': verbose_mode = 1; break; diff --git a/tests/test_rwlock.c b/tests/test_rwlock.c index b893100..4629a44 100644 --- a/tests/test_rwlock.c +++ b/tests/test_rwlock.c @@ -79,6 +79,9 @@ static unsigned long duration; /* read-side C.S. duration, in loops */ static unsigned long rduration; +/* write-side C.S. duration, in loops */ +static unsigned long wduration; + static inline void loop_sleep(unsigned long l) { while(l-- != 0) @@ -228,6 +231,8 @@ void *thr_writer(void *_count) pthread_rwlock_wrlock(&lock); test_array.a = 0; test_array.a = 8; + if (unlikely(wduration)) + loop_sleep(wduration); pthread_rwlock_unlock(&lock); nr_writes++; if (unlikely(!test_duration_write())) @@ -250,6 +255,7 @@ void show_usage(int argc, char **argv) #endif printf(" [-d delay] (writer period (us))"); printf(" [-c duration] (reader C.S. duration (in loops))"); + printf(" [-e duration] (writer C.S. duration (in loops))"); printf(" [-v] (verbose output)"); printf(" [-a cpu#] [-a cpu#]... (affinity)"); printf("\n"); @@ -324,6 +330,13 @@ int main(int argc, char **argv) } wdelay = atol(argv[++i]); break; + case 'e': + if (argc < i + 2) { + show_usage(argc, argv); + return -1; + } + wduration = atol(argv[++i]); + break; case 'v': verbose_mode = 1; break; diff --git a/tests/test_urcu.c b/tests/test_urcu.c index 0cde0b3..1ea9d07 100644 --- a/tests/test_urcu.c +++ b/tests/test_urcu.c @@ -77,6 +77,9 @@ static unsigned long duration; /* read-side C.S. duration, in loops */ static unsigned long rduration; +/* write-side C.S. duration, in loops */ +static unsigned long wduration; + static inline void loop_sleep(unsigned long l) { while(l-- != 0) @@ -272,6 +275,8 @@ void *thr_writer(void *_count) new = test_array_alloc(); new->a = 8; old = rcu_xchg_pointer(&test_rcu_pointer, new); + if (unlikely(wduration)) + loop_sleep(wduration); synchronize_rcu(); if (old) old->a = 0; @@ -297,6 +302,7 @@ void show_usage(int argc, char **argv) #endif printf(" [-d delay] (writer period (us))"); printf(" [-c duration] (reader C.S. duration (in loops))"); + printf(" [-e duration] (writer C.S. duration (in loops))"); printf(" [-v] (verbose output)"); printf(" [-a cpu#] [-a cpu#]... (affinity)"); printf("\n"); @@ -370,6 +376,13 @@ int main(int argc, char **argv) } wdelay = atol(argv[++i]); break; + case 'e': + if (argc < i + 2) { + show_usage(argc, argv); + return -1; + } + wduration = atol(argv[++i]); + break; case 'v': verbose_mode = 1; break; diff --git a/tests/test_urcu_assign.c b/tests/test_urcu_assign.c index d38361f..663a4e8 100644 --- a/tests/test_urcu_assign.c +++ b/tests/test_urcu_assign.c @@ -77,6 +77,9 @@ static unsigned long duration; /* read-side C.S. duration, in loops */ static unsigned long rduration; +/* write-side C.S. duration, in loops */ +static unsigned long wduration; + static inline void loop_sleep(unsigned long l) { while(l-- != 0) @@ -274,6 +277,8 @@ void *thr_writer(void *_count) rcu_copy_mutex_lock(); old = test_rcu_pointer; rcu_assign_pointer(test_rcu_pointer, new); + if (unlikely(wduration)) + loop_sleep(wduration); rcu_copy_mutex_unlock(); synchronize_rcu(); if (old) @@ -300,6 +305,7 @@ void show_usage(int argc, char **argv) #endif printf(" [-d delay] (writer period (us))"); printf(" [-c duration] (reader C.S. duration (in loops))"); + printf(" [-e duration] (writer C.S. duration (in loops))"); printf(" [-v] (verbose output)"); printf(" [-a cpu#] [-a cpu#]... (affinity)"); printf("\n"); @@ -373,6 +379,13 @@ int main(int argc, char **argv) } wdelay = atol(argv[++i]); break; + case 'e': + if (argc < i + 2) { + show_usage(argc, argv); + return -1; + } + wduration = atol(argv[++i]); + break; case 'v': verbose_mode = 1; break; diff --git a/tests/test_urcu_bp.c b/tests/test_urcu_bp.c index 5ba6e49..d5653b0 100644 --- a/tests/test_urcu_bp.c +++ b/tests/test_urcu_bp.c @@ -77,6 +77,9 @@ static unsigned long duration; /* read-side C.S. duration, in loops */ static unsigned long rduration; +/* write-side C.S. duration, in loops */ +static unsigned long wduration; + static inline void loop_sleep(unsigned long l) { while(l-- != 0) @@ -272,6 +275,8 @@ void *thr_writer(void *_count) new = test_array_alloc(); new->a = 8; old = rcu_xchg_pointer(&test_rcu_pointer, new); + if (unlikely(wduration)) + loop_sleep(wduration); synchronize_rcu(); if (old) old->a = 0; @@ -297,6 +302,7 @@ void show_usage(int argc, char **argv) #endif printf(" [-d delay] (writer period (us))"); printf(" [-c duration] (reader C.S. duration (in loops))"); + printf(" [-e duration] (writer C.S. duration (in loops))"); printf(" [-v] (verbose output)"); printf(" [-a cpu#] [-a cpu#]... (affinity)"); printf("\n"); @@ -370,6 +376,13 @@ int main(int argc, char **argv) } wdelay = atol(argv[++i]); break; + case 'e': + if (argc < i + 2) { + show_usage(argc, argv); + return -1; + } + wduration = atol(argv[++i]); + break; case 'v': verbose_mode = 1; break; diff --git a/tests/test_urcu_defer.c b/tests/test_urcu_defer.c index 10cd250..59a0785 100644 --- a/tests/test_urcu_defer.c +++ b/tests/test_urcu_defer.c @@ -78,6 +78,9 @@ static unsigned long duration; /* read-side C.S. duration, in loops */ static unsigned long rduration; +/* write-side C.S. duration, in loops */ +static unsigned long wduration; + static inline void loop_sleep(unsigned long l) { while(l-- != 0) @@ -250,6 +253,8 @@ void *thr_writer(void *data) new = malloc(sizeof(*new)); new->a = 8; old = rcu_xchg_pointer(&test_rcu_pointer, new); + if (unlikely(wduration)) + loop_sleep(wduration); defer_rcu(free, old); defer_rcu(test_cb1, old); defer_rcu(test_cb1, (void *)-2L); @@ -281,6 +286,7 @@ void show_usage(int argc, char **argv) #endif printf(" [-d delay] (writer period (us))"); printf(" [-c duration] (reader C.S. duration (in loops))"); + printf(" [-e duration] (writer C.S. duration (in loops))"); printf(" [-v] (verbose output)"); printf(" [-a cpu#] [-a cpu#]... (affinity)"); printf("\n"); @@ -354,6 +360,13 @@ int main(int argc, char **argv) } wdelay = atol(argv[++i]); break; + case 'e': + if (argc < i + 2) { + show_usage(argc, argv); + return -1; + } + wduration = atol(argv[++i]); + break; case 'v': verbose_mode = 1; break; diff --git a/tests/test_urcu_gc.c b/tests/test_urcu_gc.c index 4e6f965..c7b2bda 100644 --- a/tests/test_urcu_gc.c +++ b/tests/test_urcu_gc.c @@ -86,6 +86,9 @@ static unsigned long duration; /* read-side C.S. duration, in loops */ static unsigned long rduration; +/* write-side C.S. duration, in loops */ +static unsigned long wduration; + static inline void loop_sleep(unsigned long l) { while(l-- != 0) @@ -285,6 +288,8 @@ void *thr_writer(void *data) new->a = 8; old = rcu_xchg_pointer(&test_rcu_pointer, new); #endif + if (unlikely(wduration)) + loop_sleep(wduration); rcu_gc_reclaim(wtidx, old); nr_writes++; if (unlikely(!test_duration_write())) @@ -307,6 +312,7 @@ void show_usage(int argc, char **argv) #endif printf(" [-d delay] (writer period (us))"); printf(" [-c duration] (reader C.S. duration (in loops))"); + printf(" [-e duration] (writer C.S. duration (in loops))"); printf(" [-v] (verbose output)"); printf(" [-a cpu#] [-a cpu#]... (affinity)"); printf("\n"); @@ -387,6 +393,13 @@ int main(int argc, char **argv) } wdelay = atol(argv[++i]); break; + case 'e': + if (argc < i + 2) { + show_usage(argc, argv); + return -1; + } + wduration = atol(argv[++i]); + break; case 'v': verbose_mode = 1; break;