update test-mark-speed
[lttv.git] / markers-test / test-mark-speed.c
CommitLineData
f3be6faa 1/* test-mark.c
2 *
3 */
4
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>
11static void noinline test2(const struct marker *mdata,
12 void *call_private, ...)
13{
14 /* not called */
15 printk("blah\n");
16}
17
18/*
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.
25 */
26#define __my_trace_mark(generic, name, call_private, format, args...) \
27 do { \
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); \
37 if (!generic) { \
38 if (unlikely(imv_read(__mark_##name.state))) \
39 test2 \
40 (&__mark_##name, call_private, \
41 ## args); \
42 } else { \
43 if (unlikely(_imv_read(__mark_##name.state))) \
44 test2 \
45 (&__mark_##name, call_private, \
46 ## args); \
47 } \
48 } while (0)
49
50 //asm volatile ("");
51struct proc_dir_entry *pentry = NULL;
52
53static inline void test(unsigned long arg, unsigned long arg2)
54{
55 //asm volatile ("");
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);
58}
59
60static int my_open(struct inode *inode, struct file *file)
61{
62 unsigned int i;
63 cycles_t cycles1, cycles2;
64 unsigned long flags;
65
66 local_irq_save(flags);
67 rdtsc_barrier();
68 cycles1 = get_cycles();
69 rdtsc_barrier();
70 for(i=0; i<20000; i++) {
71 test(i, i);
72 }
73 rdtsc_barrier();
74 cycles2 = get_cycles();
75 rdtsc_barrier();
76 local_irq_restore(flags);
77 printk("cycles : %llu\n", cycles2-cycles1);
78 return -EPERM;
79}
80
81
82static struct file_operations my_operations = {
83 .open = my_open,
84};
85
86int init_module(void)
87{
88 pentry = create_proc_entry("testmark", 0444, NULL);
89 if (pentry)
90 pentry->proc_fops = &my_operations;
91
92 return 0;
93}
94
95void cleanup_module(void)
96{
97 remove_proc_entry("testmark", NULL);
98}
99
100MODULE_LICENSE("GPL");
101MODULE_AUTHOR("Mathieu Desnoyers");
102MODULE_DESCRIPTION("Marker Test");
103
This page took 0.025824 seconds and 4 git commands to generate.