add missing tests
[lttv.git] / tests / kernel / test-cmpxchg.c
CommitLineData
02e6c126 1/* test-cmpxchg.c
2 *
3 * Test time spent in a LTTng instrumentation probe.
4 */
5
6
cad735b5 7#include <linux/config.h>
8#include <linux/jiffies.h>
9#include <linux/compiler.h>
02e6c126 10#include <linux/init.h>
11#include <linux/module.h>
02e6c126 12
d254c2d4 13#define NR_LOOPS 20000
14
cad735b5 15volatile int test_val = 100;
16
02e6c126 17
38b8d96b 18static inline void do_test(void)
02e6c126 19{
cad735b5 20 int val, ret;
02e6c126 21
22 val = test_val;
23
cad735b5 24 ret = cmpxchg(&test_val, val, val+1);
02e6c126 25}
26
38b8d96b 27//void (*fct)(void) = do_test;
cad735b5 28
02e6c126 29static int ltt_test_init(void)
30{
31 unsigned int i;
32 cycles_t time1, time2, time;
33 cycles_t max_time = 0, min_time = 18446744073709551615ULL; /* (2^64)-1 */
34 cycles_t tot_time = 0;
35 unsigned long flags;
36 printk(KERN_ALERT "test init\n");
37
38 local_irq_save(flags);
cad735b5 39 time1 = get_cycles();
02e6c126 40 for(i=0; i<NR_LOOPS; i++) {
cad735b5 41 //for(int j=0; j<10; j++) {
02e6c126 42 do_test();
cad735b5 43 //}
44 //max_time = max(max_time, time);
45 //min_time = min(min_time, time);
46 //printk("val : %d\n", test_val);
02e6c126 47 }
cad735b5 48 time2 = get_cycles();
02e6c126 49 local_irq_restore(flags);
cad735b5 50 time = time2 - time1;
51 tot_time += time;
02e6c126 52
53 printk(KERN_ALERT "test results : time per probe\n");
54 printk(KERN_ALERT "number of loops : %d\n", NR_LOOPS);
55 printk(KERN_ALERT "total time : %llu\n", tot_time);
cad735b5 56 //printk(KERN_ALERT "min : %llu\n", min_time);
57 //printk(KERN_ALERT "max : %llu\n", max_time);
02e6c126 58
59 printk(KERN_ALERT "test end\n");
60
61 return -EAGAIN; /* Fail will directly unload the module */
62}
63
64static void ltt_test_exit(void)
65{
66 printk(KERN_ALERT "test exit\n");
67}
68
69module_init(ltt_test_init)
70module_exit(ltt_test_exit)
71
72MODULE_LICENSE("GPL");
73MODULE_AUTHOR("Mathieu Desnoyers");
74MODULE_DESCRIPTION("Linux Trace Toolkit Test");
75
This page took 0.026119 seconds and 4 git commands to generate.