3 * Connects a two functions to marker call sites.
5 * (C) Copyright 2007 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
7 * This file is released under the GPLv2.
8 * See the file COPYING for more details.
11 #include <linux/sched.h>
12 #include <linux/kernel.h>
13 #include <linux/module.h>
14 #include <linux/marker.h>
15 #include <asm/atomic.h>
17 #define NUM_PROBES (sizeof(probe_array) / sizeof(struct probe_data))
22 marker_probe_func
*probe_func
;
25 void probe_subsystem_event(const struct __mark_marker_c
*mdata
,
26 const char *format
, ...)
32 int task_size
, task_alignment
;
33 struct task_struct
*task
;
37 value
= va_arg(ap
, typeof(value
));
38 mystr
= va_arg(ap
, typeof(mystr
));
39 task_size
= va_arg(ap
, typeof(task_size
));
40 task_alignment
= va_arg(ap
, typeof(task_alignment
));
41 task
= va_arg(ap
, typeof(task
));
44 printk("Value %u, string %s, current ptr %p\n", value
, mystr
, current
);
46 /* or count, check rights, serialize data in a buffer */
51 atomic_t eventb_count
= ATOMIC_INIT(0);
53 void probe_subsystem_eventb(const struct __mark_marker_c
*mdata
,
54 const char *format
, ...)
56 /* Increment counter */
57 atomic_inc(&eventb_count
);
60 static struct probe_data probe_array
[] =
62 { .name
= "subsystem_event",
63 .format
= "%d %s %*.*r",
64 .probe_func
= probe_subsystem_event
},
65 { .name
= "subsystem_eventb",
66 .format
= MARK_NOARGS
,
67 .probe_func
= probe_subsystem_eventb
},
70 static int __init
probe_init(void)
75 for (eID
= 0; eID
< NUM_PROBES
; eID
++) {
76 result
= marker_set_probe(probe_array
[eID
].name
,
77 probe_array
[eID
].format
,
78 probe_array
[eID
].probe_func
, &probe_array
[eID
]);
80 printk(KERN_INFO
"Unable to register probe %s\n",
81 probe_array
[eID
].name
);
86 static void __exit
probe_fini(void)
90 for (eID
= 0; eID
< NUM_PROBES
; eID
++) {
91 marker_remove_probe(probe_array
[eID
].name
);
93 synchronize_sched(); /* Wait for probes to finish */
94 printk("Number of event b : %u\n", atomic_read(&eventb_count
));
97 module_init(probe_init
);
98 module_exit(probe_fini
);
100 MODULE_LICENSE("GPL");
101 MODULE_AUTHOR("Mathieu Desnoyers");
102 MODULE_DESCRIPTION("SUBSYSTEM Probe");
This page took 0.079721 seconds and 4 git commands to generate.