5 #include <linux/module.h>
6 #include <linux/proc_fs.h>
7 #include <linux/sched.h>
8 #include <linux/timex.h>
9 #include <linux/marker.h>
10 #include <asm/ptrace.h>
11 static void noinline
test2(const struct marker
*mdata
,
12 void *call_private
, ...)
19 * Generic marker flavor always available.
20 * Note : the empty asm volatile with read constraint is used here instead of a
21 * "used" attribute to fix a gcc 4.1.x bug.
22 * Make sure the alignment of the structure in the __markers section will
23 * not add unwanted padding between the beginning of the section and the
24 * structure. Force alignment to the same alignment as the section start.
26 #define __my_trace_mark(generic, name, call_private, format, args...) \
28 static const char __mstrtab_##name[] \
29 __attribute__((section("__markers_strings"))) \
30 = #name "\0" format; \
31 static struct marker __mark_##name \
32 __attribute__((section("__markers"), aligned(8))) = \
33 { __mstrtab_##name, &__mstrtab_##name[sizeof(#name)], \
34 0, 0, marker_probe_cb, \
35 { __mark_empty_function, NULL}, NULL }; \
36 __mark_check_format(format, ## args); \
38 if (unlikely(imv_read(__mark_##name.state))) \
40 (&__mark_##name, call_private, \
43 if (unlikely(_imv_read(__mark_##name.state))) \
45 (&__mark_##name, call_private, \
51 struct proc_dir_entry
*pentry
= NULL
;
53 static inline void test(unsigned long arg
, unsigned long arg2
)
56 __my_trace_mark(1, kernel_debug_test
, NULL
, "%d %d %ld %ld", 2, current
->pid
, arg
, arg2
);
57 //__my_trace_mark(0, kernel_debug_test, NULL, "%d %d %ld %ld", 2, current->pid, arg, arg2);
60 static int my_open(struct inode
*inode
, struct file
*file
)
63 cycles_t cycles1
, cycles2
;
66 local_irq_save(flags
);
68 cycles1
= get_cycles();
70 for(i
=0; i
<20000; i
++) {
74 cycles2
= get_cycles();
76 local_irq_restore(flags
);
77 printk("cycles : %llu\n", cycles2
-cycles1
);
82 static struct file_operations my_operations
= {
88 pentry
= create_proc_entry("testmark", 0444, NULL
);
90 pentry
->proc_fops
= &my_operations
;
95 void cleanup_module(void)
97 remove_proc_entry("testmark", NULL
);
100 MODULE_LICENSE("GPL");
101 MODULE_AUTHOR("Mathieu Desnoyers");
102 MODULE_DESCRIPTION("Marker Test");