3 * Test time spent in a LTTng instrumentation probe.
7 #include <linux/init.h>
8 #include <linux/module.h>
9 #include <linux/ltt-tracer.h>
10 #include <linux/timex.h>
11 #include <linux/marker.h>
12 #include <linux/proc_fs.h>
14 struct proc_dir_entry
*pentry_test
= NULL
;
16 /* Event logged : 4 bytes. Let's use 1MB of
17 * buffers. 1MB / 4bytes = 262144 (plus heartbeats). So, if we write 20000
18 * event, we should not lose events. Check event lost count after tests. */
20 #define NR_LOOPS 20000
22 static int my_open(struct inode
*inode
, struct file
*file
)
25 cycles_t time1
, time2
, time
;
26 cycles_t tot_time
= 0;
29 printk(KERN_ALERT
"test begin\n");
30 local_irq_save(flags
);
32 for(i
=0; i
<NR_LOOPS
; i
++) {
33 _MARK(_MF_DEFAULT
| ltt_flag_mask(LTT_FLAG_COMPACT
),
34 compact_event_a
, MARK_NOARGS
);
35 _MARK(_MF_DEFAULT
| ltt_flag_mask(LTT_FLAG_COMPACT
),
36 compact_event_b
, "%4b", 0xFFFF);
37 _MARK(_MF_DEFAULT
| ltt_flag_mask(LTT_FLAG_COMPACT
),
38 compact_event_c
, "%8b", 0xFFFFFFFFULL
);
39 _MARK(_MF_DEFAULT
| ltt_flag_mask(LTT_FLAG_COMPACT
)
40 | ltt_flag_mask(LTT_FLAG_COMPACT_DATA
),
41 compact_event_d
, MARK_NOARGS
, 0xFFFF);
42 _MARK(_MF_DEFAULT
| ltt_flag_mask(LTT_FLAG_COMPACT
)
43 | ltt_flag_mask(LTT_FLAG_COMPACT_DATA
),
44 compact_event_e
, "%8b", 0xFFFF, 0xFFFFFFFFULL
);
49 local_irq_restore(flags
);
51 printk(KERN_ALERT
"test results : time per probe\n");
52 printk(KERN_ALERT
"number of loops : %d\n", NR_LOOPS
);
53 printk(KERN_ALERT
"total time : %llu\n", tot_time
);
55 printk(KERN_ALERT
"test end\n");
59 static struct file_operations mark_ops
= {
63 static int ltt_test_init(void)
65 printk(KERN_ALERT
"test init\n");
66 pentry_test
= create_proc_entry("test-compact", 0444, NULL
);
68 pentry_test
->proc_fops
= &mark_ops
;
74 static void ltt_test_exit(void)
76 printk(KERN_ALERT
"test exit\n");
77 remove_proc_entry("test-compact", NULL
);
80 module_init(ltt_test_init
)
81 module_exit(ltt_test_exit
)
83 MODULE_LICENSE("GPL");
84 MODULE_AUTHOR("Mathieu Desnoyers");
85 MODULE_DESCRIPTION("Linux Trace Toolkit Test");
This page took 0.029762 seconds and 4 git commands to generate.