3
* Connects 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>
20
marker_probe_func *probe_func;
23
static void probe_subsystem_event(const struct marker *mdata,
24
void *probe_data, void *call_data,
25
const char *format, va_list *args)
32
value = va_arg(*args, typeof(value));
33
mystr = va_arg(*args, typeof(mystr));
36
printk(KERN_INFO "Value %u, string %s\n", value, mystr);
38
/* or count, check rights, serialize data in a buffer */
41
atomic_t eventb_count = ATOMIC_INIT(0);
43
static void probe_subsystem_eventb(const struct marker *mdata,
44
void *probe_data, void *call_data,
45
const char *format, va_list *args)
47
/* Increment counter */
48
atomic_inc(&eventb_count);
51
static struct probe_data probe_array[] =
53
{ .name = "subsystem_event",
54
.format = "integer %d string %s",
55
.probe_func = probe_subsystem_event },
56
{ .name = "subsystem_eventb",
57
.format = MARK_NOARGS,
58
.probe_func = probe_subsystem_eventb },
61
static int __init probe_init(void)
66
for (i = 0; i < ARRAY_SIZE(probe_array); i++) {
67
result = marker_probe_register("samples", probe_array[i].name,
68
probe_array[i].format,
69
probe_array[i].probe_func, &probe_array[i]);
71
printk(KERN_INFO "Unable to register probe %s\n",
77
static void __exit probe_fini(void)
81
for (i = 0; i < ARRAY_SIZE(probe_array); i++)
82
marker_probe_unregister("samples", probe_array[i].name,
83
probe_array[i].probe_func, &probe_array[i]);
84
printk(KERN_INFO "Number of event b : %u\n",
85
atomic_read(&eventb_count));
86
marker_synchronize_unregister();
89
module_init(probe_init);
90
module_exit(probe_fini);
92
MODULE_LICENSE("GPL");
93
MODULE_AUTHOR("Mathieu Desnoyers");
94
MODULE_DESCRIPTION("SUBSYSTEM Probe");