convert from svn repository: remove tags directory
[lttv.git] / trunk / tests / kernel / test-compact.c
CommitLineData
c9a9c80f 1/* test-time-probe.c
2 *
3 * Test time spent in a LTTng instrumentation probe.
4 */
5
6
c9a9c80f 7#include <linux/init.h>
8#include <linux/module.h>
421991b0 9#include <linux/ltt-tracer.h>
c99ee580 10#include <linux/timex.h>
d06fc4d5 11#include <linux/marker.h>
12#include <linux/proc_fs.h>
c9a9c80f 13
d06fc4d5 14struct proc_dir_entry *pentry_test = NULL;
c9a9c80f 15
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. */
19
20#define NR_LOOPS 20000
21
d06fc4d5 22static int my_open(struct inode *inode, struct file *file)
c9a9c80f 23{
24 unsigned int i;
25 cycles_t time1, time2, time;
26 cycles_t tot_time = 0;
27 unsigned long flags;
c9a9c80f 28
d06fc4d5 29 printk(KERN_ALERT "test begin\n");
c9a9c80f 30 local_irq_save(flags);
31 time1 = get_cycles();
32 for(i=0; i<NR_LOOPS; i++) {
d06fc4d5 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);
c9a9c80f 45 }
46 time2 = get_cycles();
47 time = time2 - time1;
48 tot_time += time;
49 local_irq_restore(flags);
50
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);
54
55 printk(KERN_ALERT "test end\n");
d06fc4d5 56 return -EPERM;
57}
58
59static struct file_operations mark_ops = {
60 .open = my_open,
61};
62
63static int ltt_test_init(void)
64{
65 printk(KERN_ALERT "test init\n");
66 pentry_test = create_proc_entry("test-compact", 0444, NULL);
67 if (pentry_test)
68 pentry_test->proc_fops = &mark_ops;
69 else
70 return -EPERM;
71 return 0;
c9a9c80f 72}
73
74static void ltt_test_exit(void)
75{
76 printk(KERN_ALERT "test exit\n");
d06fc4d5 77 remove_proc_entry("test-compact", NULL);
c9a9c80f 78}
79
80module_init(ltt_test_init)
81module_exit(ltt_test_exit)
82
83MODULE_LICENSE("GPL");
84MODULE_AUTHOR("Mathieu Desnoyers");
85MODULE_DESCRIPTION("Linux Trace Toolkit Test");
86
This page took 0.032024 seconds and 4 git commands to generate.