diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2009-10-17 19:09:09 -0400 |
---|---|---|
committer | Frederic Weisbecker <fweisbec@gmail.com> | 2009-10-17 19:12:33 -0400 |
commit | 0f8f86c7bdd1c954fbe153af437a0d91a6c5721a (patch) | |
tree | 94a8d419a470a4f9852ca397bb9bbe48db92ff5c /samples | |
parent | dca2d6ac09d9ef59ff46820d4f0c94b08a671202 (diff) | |
parent | f39cdf25bf77219676ec5360980ac40b1a7e144a (diff) |
Merge commit 'perf/core' into perf/hw-breakpoint
Conflicts:
kernel/Makefile
kernel/trace/Makefile
kernel/trace/trace.h
samples/Makefile
Merge reason: We need to be uptodate with the perf events development
branch because we plan to rewrite the breakpoints API on top of
perf events.
Diffstat (limited to 'samples')
-rw-r--r-- | samples/Kconfig | 6 | ||||
-rw-r--r-- | samples/Makefile | 4 | ||||
-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 | ||||
-rw-r--r-- | samples/trace_events/trace-events-sample.h | 2 | ||||
-rw-r--r-- | samples/tracepoints/tracepoint-sample.c | 2 |
7 files changed, 4 insertions, 159 deletions
diff --git a/samples/Kconfig b/samples/Kconfig index 17d64ba7864c..e4be84ac3d38 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 42e175598777..0f15e6d77fd6 100644 --- a/samples/Makefile +++ b/samples/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | # Makefile for Linux samples code | 1 | # Makefile for Linux samples code |
2 | 2 | ||
3 | obj-$(CONFIG_SAMPLES) += markers/ kobject/ kprobes/ tracepoints/ \ | 3 | obj-$(CONFIG_SAMPLES) += kobject/ kprobes/ tracepoints/ trace_events/ \ |
4 | trace_events/ hw_breakpoint/ | 4 | hw_breakpoint/ |
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"); | ||
diff --git a/samples/trace_events/trace-events-sample.h b/samples/trace_events/trace-events-sample.h index f24ae370e514..6af373236d73 100644 --- a/samples/trace_events/trace-events-sample.h +++ b/samples/trace_events/trace-events-sample.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * If TRACE_SYSTEM is defined, that will be the directory created | 2 | * If TRACE_SYSTEM is defined, that will be the directory created |
3 | * in the ftrace directory under /debugfs/tracing/events/<system> | 3 | * in the ftrace directory under /sys/kernel/debug/tracing/events/<system> |
4 | * | 4 | * |
5 | * The define_trace.h below will also look for a file name of | 5 | * The define_trace.h below will also look for a file name of |
6 | * TRACE_SYSTEM.h where TRACE_SYSTEM is what is defined here. | 6 | * TRACE_SYSTEM.h where TRACE_SYSTEM is what is defined here. |
diff --git a/samples/tracepoints/tracepoint-sample.c b/samples/tracepoints/tracepoint-sample.c index 9cf80a11e8b6..26fab33ffa8c 100644 --- a/samples/tracepoints/tracepoint-sample.c +++ b/samples/tracepoints/tracepoint-sample.c | |||
@@ -28,7 +28,7 @@ static int my_open(struct inode *inode, struct file *file) | |||
28 | return -EPERM; | 28 | return -EPERM; |
29 | } | 29 | } |
30 | 30 | ||
31 | static struct file_operations mark_ops = { | 31 | static const struct file_operations mark_ops = { |
32 | .open = my_open, | 32 | .open = my_open, |
33 | }; | 33 | }; |
34 | 34 | ||