From 02e6c12634c5e4e473c5df88ba537502d046b882 Mon Sep 17 00:00:00 2001 From: compudj Date: Mon, 29 May 2006 12:38:22 +0000 Subject: [PATCH] add test git-svn-id: http://ltt.polymtl.ca/svn@1863 04897980-b3bd-0310-b5e0-8ef037075253 --- tests/kernel/Makefile | 1 + tests/kernel/test-cmpxchg.c | 68 +++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 tests/kernel/test-cmpxchg.c diff --git a/tests/kernel/Makefile b/tests/kernel/Makefile index 8ee754f9..a2985567 100644 --- a/tests/kernel/Makefile +++ b/tests/kernel/Makefile @@ -6,6 +6,7 @@ ifneq ($(CONFIG_LTT),) obj-m += test-instrument-size-med.o obj-m += test-instrument-size-big.o obj-m += test-printk-effect.o + obj-m += test-cmpxchg.o endif else diff --git a/tests/kernel/test-cmpxchg.c b/tests/kernel/test-cmpxchg.c new file mode 100644 index 00000000..a8166331 --- /dev/null +++ b/tests/kernel/test-cmpxchg.c @@ -0,0 +1,68 @@ +/* test-cmpxchg.c + * + * Test time spent in a LTTng instrumentation probe. + */ + + +#include +#include +#include +#include + +#define NR_LOOPS 2000 + +static volatile int test_val = 100; + +static void do_test(void) +{ + int val; + + val = test_val; + + ret = cmpxchg(&test_val, val, 101); +} + +static int ltt_test_init(void) +{ + unsigned int i; + cycles_t time1, time2, time; + cycles_t max_time = 0, min_time = 18446744073709551615ULL; /* (2^64)-1 */ + cycles_t tot_time = 0; + unsigned long flags; + printk(KERN_ALERT "test init\n"); + + local_irq_save(flags); + for(i=0; i