diff options
Diffstat (limited to 'samples')
-rw-r--r-- | samples/Kconfig | 6 | ||||
-rw-r--r-- | samples/Makefile | 2 | ||||
-rw-r--r-- | samples/markers/Makefile | 4 | ||||
-rw-r--r-- | samples/markers/marker-example.c | 53 | ||||
-rw-r--r-- | samples/markers/probe-example.c | 92 |
5 files changed, 1 insertions, 156 deletions
diff --git a/samples/Kconfig b/samples/Kconfig index 428b065ba695..b92bde3c6a89 100644 --- a/samples/Kconfig +++ b/samples/Kconfig | |||
@@ -7,12 +7,6 @@ menuconfig SAMPLES | |||
7 | 7 | ||
8 | if SAMPLES | 8 | if SAMPLES |
9 | 9 | ||
10 | config SAMPLE_MARKERS | ||
11 | tristate "Build markers examples -- loadable modules only" | ||
12 | depends on MARKERS && m | ||
13 | help | ||
14 | This build markers example modules. | ||
15 | |||
16 | config SAMPLE_TRACEPOINTS | 10 | config SAMPLE_TRACEPOINTS |
17 | tristate "Build tracepoints examples -- loadable modules only" | 11 | tristate "Build tracepoints examples -- loadable modules only" |
18 | depends on TRACEPOINTS && m | 12 | depends on TRACEPOINTS && m |
diff --git a/samples/Makefile b/samples/Makefile index 13e4b470b539..43343a03b1f4 100644 --- a/samples/Makefile +++ b/samples/Makefile | |||
@@ -1,3 +1,3 @@ | |||
1 | # Makefile for Linux samples code | 1 | # Makefile for Linux samples code |
2 | 2 | ||
3 | obj-$(CONFIG_SAMPLES) += markers/ kobject/ kprobes/ tracepoints/ trace_events/ | 3 | obj-$(CONFIG_SAMPLES) += kobject/ kprobes/ tracepoints/ trace_events/ |
diff --git a/samples/markers/Makefile b/samples/markers/Makefile deleted file mode 100644 index 6d7231265f0f..000000000000 --- a/samples/markers/Makefile +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | # builds the kprobes example kernel modules; | ||
2 | # then to use one (as root): insmod <module_name.ko> | ||
3 | |||
4 | obj-$(CONFIG_SAMPLE_MARKERS) += probe-example.o marker-example.o | ||
diff --git a/samples/markers/marker-example.c b/samples/markers/marker-example.c deleted file mode 100644 index e9cd9c0bc84f..000000000000 --- a/samples/markers/marker-example.c +++ /dev/null | |||
@@ -1,53 +0,0 @@ | |||
1 | /* marker-example.c | ||
2 | * | ||
3 | * Executes a marker when /proc/marker-example is opened. | ||
4 | * | ||
5 | * (C) Copyright 2007 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> | ||
6 | * | ||
7 | * This file is released under the GPLv2. | ||
8 | * See the file COPYING for more details. | ||
9 | */ | ||
10 | |||
11 | #include <linux/module.h> | ||
12 | #include <linux/marker.h> | ||
13 | #include <linux/sched.h> | ||
14 | #include <linux/proc_fs.h> | ||
15 | |||
16 | struct proc_dir_entry *pentry_example; | ||
17 | |||
18 | static int my_open(struct inode *inode, struct file *file) | ||
19 | { | ||
20 | int i; | ||
21 | |||
22 | trace_mark(subsystem_event, "integer %d string %s", 123, | ||
23 | "example string"); | ||
24 | for (i = 0; i < 10; i++) | ||
25 | trace_mark(subsystem_eventb, MARK_NOARGS); | ||
26 | return -EPERM; | ||
27 | } | ||
28 | |||
29 | static struct file_operations mark_ops = { | ||
30 | .open = my_open, | ||
31 | }; | ||
32 | |||
33 | static int __init example_init(void) | ||
34 | { | ||
35 | printk(KERN_ALERT "example init\n"); | ||
36 | pentry_example = proc_create("marker-example", 0444, NULL, &mark_ops); | ||
37 | if (!pentry_example) | ||
38 | return -EPERM; | ||
39 | return 0; | ||
40 | } | ||
41 | |||
42 | static void __exit example_exit(void) | ||
43 | { | ||
44 | printk(KERN_ALERT "example exit\n"); | ||
45 | remove_proc_entry("marker-example", NULL); | ||
46 | } | ||
47 | |||
48 | module_init(example_init) | ||
49 | module_exit(example_exit) | ||
50 | |||
51 | MODULE_LICENSE("GPL"); | ||
52 | MODULE_AUTHOR("Mathieu Desnoyers"); | ||
53 | MODULE_DESCRIPTION("Marker example"); | ||
diff --git a/samples/markers/probe-example.c b/samples/markers/probe-example.c deleted file mode 100644 index 2dfb3b32937e..000000000000 --- a/samples/markers/probe-example.c +++ /dev/null | |||
@@ -1,92 +0,0 @@ | |||
1 | /* probe-example.c | ||
2 | * | ||
3 | * Connects two functions to marker call sites. | ||
4 | * | ||
5 | * (C) Copyright 2007 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> | ||
6 | * | ||
7 | * This file is released under the GPLv2. | ||
8 | * See the file COPYING for more details. | ||
9 | */ | ||
10 | |||
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> | ||
16 | |||
17 | struct probe_data { | ||
18 | const char *name; | ||
19 | const char *format; | ||
20 | marker_probe_func *probe_func; | ||
21 | }; | ||
22 | |||
23 | void probe_subsystem_event(void *probe_data, void *call_data, | ||
24 | const char *format, va_list *args) | ||
25 | { | ||
26 | /* Declare args */ | ||
27 | unsigned int value; | ||
28 | const char *mystr; | ||
29 | |||
30 | /* Assign args */ | ||
31 | value = va_arg(*args, typeof(value)); | ||
32 | mystr = va_arg(*args, typeof(mystr)); | ||
33 | |||
34 | /* Call printk */ | ||
35 | printk(KERN_INFO "Value %u, string %s\n", value, mystr); | ||
36 | |||
37 | /* or count, check rights, serialize data in a buffer */ | ||
38 | } | ||
39 | |||
40 | atomic_t eventb_count = ATOMIC_INIT(0); | ||
41 | |||
42 | void probe_subsystem_eventb(void *probe_data, void *call_data, | ||
43 | const char *format, va_list *args) | ||
44 | { | ||
45 | /* Increment counter */ | ||
46 | atomic_inc(&eventb_count); | ||
47 | } | ||
48 | |||
49 | static struct probe_data probe_array[] = | ||
50 | { | ||
51 | { .name = "subsystem_event", | ||
52 | .format = "integer %d string %s", | ||
53 | .probe_func = probe_subsystem_event }, | ||
54 | { .name = "subsystem_eventb", | ||
55 | .format = MARK_NOARGS, | ||
56 | .probe_func = probe_subsystem_eventb }, | ||
57 | }; | ||
58 | |||
59 | static int __init probe_init(void) | ||
60 | { | ||
61 | int result; | ||
62 | int i; | ||
63 | |||
64 | for (i = 0; i < ARRAY_SIZE(probe_array); i++) { | ||
65 | result = marker_probe_register(probe_array[i].name, | ||
66 | probe_array[i].format, | ||
67 | probe_array[i].probe_func, &probe_array[i]); | ||
68 | if (result) | ||
69 | printk(KERN_INFO "Unable to register probe %s\n", | ||
70 | probe_array[i].name); | ||
71 | } | ||
72 | return 0; | ||
73 | } | ||
74 | |||
75 | static void __exit probe_fini(void) | ||
76 | { | ||
77 | int i; | ||
78 | |||
79 | for (i = 0; i < ARRAY_SIZE(probe_array); i++) | ||
80 | marker_probe_unregister(probe_array[i].name, | ||
81 | probe_array[i].probe_func, &probe_array[i]); | ||
82 | printk(KERN_INFO "Number of event b : %u\n", | ||
83 | atomic_read(&eventb_count)); | ||
84 | marker_synchronize_unregister(); | ||
85 | } | ||
86 | |||
87 | module_init(probe_init); | ||
88 | module_exit(probe_fini); | ||
89 | |||
90 | MODULE_LICENSE("GPL"); | ||
91 | MODULE_AUTHOR("Mathieu Desnoyers"); | ||
92 | MODULE_DESCRIPTION("SUBSYSTEM Probe"); | ||