3 * Test lttng event write.
6 #include <linux/jiffies.h>
7 #include <linux/compiler.h>
8 #include <linux/init.h>
9 #include <linux/module.h>
10 #include <linux/math64.h>
11 #include <linux/proc_fs.h>
13 #include <asm/timex.h>
14 #include <asm/system.h>
16 #define NR_LOOPS 200000
18 DEFINE_TRACE(kernel_test
);
20 struct proc_dir_entry
*pentry
= NULL
;
24 static void do_testbaseline(void)
28 cycles_t time1
, time2
, time
;
31 local_irq_save(flags
);
34 for (i
= 0; i
< NR_LOOPS
; i
++) {
38 local_irq_restore(flags
);
42 printk(KERN_ALERT
"test results: time for baseline\n");
43 printk(KERN_ALERT
"number of loops: %d\n", NR_LOOPS
);
44 printk(KERN_ALERT
"total time: %llu\n", time
);
45 time
= div_u64_rem(time
, NR_LOOPS
, &rem
);
46 printk(KERN_ALERT
"-> baseline takes %llu cycles\n", time
);
47 printk(KERN_ALERT
"test end\n");
50 static void do_test_tp(void)
54 cycles_t time1
, time2
, time
;
57 local_irq_save(flags
);
60 for (i
= 0; i
< NR_LOOPS
; i
++) {
61 trace_kernel_test((void *)999, (void *)10);
64 local_irq_restore(flags
);
68 printk(KERN_ALERT
"test results: time for one probe\n");
69 printk(KERN_ALERT
"number of loops: %d\n", NR_LOOPS
);
70 printk(KERN_ALERT
"total time: %llu\n", time
);
71 time
= div_u64_rem(time
, NR_LOOPS
, &rem
);
72 printk(KERN_ALERT
"-> one probe takes %llu cycles\n", time
);
73 printk(KERN_ALERT
"test end\n");
76 static int my_open(struct inode
*inode
, struct file
*file
)
84 static const struct file_operations my_operations
= {
88 static int ltt_test_init(void)
90 printk(KERN_ALERT
"test init\n");
91 pentry
= create_proc_entry("testltt", 0444, NULL
);
93 pentry
->proc_fops
= &my_operations
;
97 static void ltt_test_exit(void)
99 printk(KERN_ALERT
"test exit\n");
100 remove_proc_entry("testltt", NULL
);
103 module_init(ltt_test_init
)
104 module_exit(ltt_test_exit
)
106 MODULE_LICENSE("GPL");
107 MODULE_AUTHOR("Mathieu Desnoyers");
108 MODULE_DESCRIPTION("TP test");