From: compudj Date: Thu, 21 May 2009 19:05:09 +0000 (+0000) Subject: update rwlock X-Git-Tag: v0.12.20~98 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=6bc6dad33f2ba75c4023609bd0f67e4bf7718c47;p=lttv.git update rwlock git-svn-id: http://ltt.polymtl.ca/svn@3391 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/trunk/tests/kernel/test-read-lock-speed.c b/trunk/tests/kernel/test-read-lock-speed.c index 31e40f10..979f1bc8 100644 --- a/trunk/tests/kernel/test-read-lock-speed.c +++ b/trunk/tests/kernel/test-read-lock-speed.c @@ -2,8 +2,8 @@ * test-read-lock-speed.c * * Compare speed of : - * - spin lock irqsave / spin unlock irqrestore (close to rwlocks when - * uncontended) + * - spin lock irqsave / spin unlock irqrestore (protects from interrupts) + * - rwlock read lock (not disabling interrupts, can deal with nesting) * - using a sequence read lock (uncontended) * - preempt disable/enable (RCU) * @@ -96,6 +96,36 @@ static void do_test_spinlock(void) printk(KERN_ALERT "test end\n"); } +static void do_test_read_rwlock(void) +{ + static DEFINE_RWLOCK(mylock); + unsigned long flags; + unsigned int i; + cycles_t time1, time2, time; + u32 rem; + + preempt_disable(); + local_irq_save(flags); + read_lock(&mylock); + time1 = get_cycles(); + for (i = 0; i < NR_LOOPS; i++) { + read_unlock(&mylock); + read_lock(&mylock); + } + time2 = get_cycles(); + read_unlock(&mylock); + local_irq_restore(flags); + preempt_enable(); + time = time2 - time1; + + printk(KERN_ALERT "test results: time for read rwlock\n"); + printk(KERN_ALERT "number of loops: %d\n", NR_LOOPS); + printk(KERN_ALERT "total time: %llu\n", time); + time = div_u64_rem(time, NR_LOOPS, &rem); + printk(KERN_ALERT "-> read rwlock takes %llu cycles\n", time); + printk(KERN_ALERT "test end\n"); +} + static void do_test_seqlock(void) { static seqlock_t test_lock; @@ -166,6 +196,7 @@ static int ltt_test_init(void) printk(KERN_ALERT "Number of active CPUs : %d\n", num_online_cpus()); do_testbaseline(); do_test_spinlock(); + do_test_read_rwlock(); do_test_seqlock(); do_test_preempt(); return -EAGAIN; /* Fail will directly unload the module */