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
, ...)
35 value
= va_arg(ap
, typeof(value
));
36 mystr
= va_arg(ap
, typeof(mystr
));
39 printk("Value %u, string %s\n", value
, mystr
);
41 /* or count, check rights, serialize data in a buffer */
46 atomic_t eventb_count
= ATOMIC_INIT(0);
48 void probe_subsystem_eventb(const struct __mark_marker_c
*mdata
,
49 const char *format
, ...)
51 /* Increment counter */
52 atomic_inc(&eventb_count
);
55 static struct probe_data probe_array
[] =
57 { .name
= "subsystem_event",
59 .probe_func
= probe_subsystem_event
},
60 { .name
= "subsystem_eventb",
61 .format
= MARK_NOARGS
,
62 .probe_func
= probe_subsystem_eventb
},
65 static int __init
probe_init(void)
70 for (eID
= 0; eID
< NUM_PROBES
; eID
++) {
71 result
= marker_set_probe(probe_array
[eID
].name
,
72 probe_array
[eID
].format
,
73 probe_array
[eID
].probe_func
, &probe_array
[eID
]);
75 printk(KERN_INFO
"Unable to register probe %s\n",
76 probe_array
[eID
].name
);
81 static void __exit
probe_fini(void)
85 for (eID
= 0; eID
< NUM_PROBES
; eID
++) {
86 marker_remove_probe(probe_array
[eID
].name
);
88 synchronize_sched(); /* Wait for probes to finish */
89 printk("Number of event b : %u\n", atomic_read(&eventb_count
));
92 module_init(probe_init
);
93 module_exit(probe_fini
);
95 MODULE_LICENSE("GPL");
96 MODULE_AUTHOR("Mathieu Desnoyers");
97 MODULE_DESCRIPTION("SUBSYSTEM Probe");
This page took 0.083233 seconds and 4 git commands to generate.