diff options
| author | Steven Rostedt <srostedt@redhat.com> | 2013-01-25 09:46:36 -0500 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2013-01-25 11:22:11 -0500 |
| commit | d75f717e19fe595e7efbf67de195ada8d89dfbbe (patch) | |
| tree | 26e00856e0595ee4fa5c54fd5c457d62d86c3ff1 /samples/tracepoints | |
| parent | b736f48bda54ec75b7dc9306884c3843f1a78a0a (diff) | |
tracing: Remove tracepoint sample code
The tracepoint sample code was used to teach developers how to
create their own tracepoints. But now the trace_events have been
added as a higher level that is used directly by developers today.
Only the trace_event code should use the tracepoint interface
directly and no new tracepoints should be added.
Besides, the example had a race condition with the use of the
->d_name.name dentry field, as pointed out by Al Viro.
Best just to remove the code so it wont be used by other developers.
Link: http://lkml.kernel.org/r/20130123225523.GY4939@ZenIV.linux.org.uk
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'samples/tracepoints')
| -rw-r--r-- | samples/tracepoints/Makefile | 6 | ||||
| -rw-r--r-- | samples/tracepoints/tp-samples-trace.h | 11 | ||||
| -rw-r--r-- | samples/tracepoints/tracepoint-probe-sample.c | 57 | ||||
| -rw-r--r-- | samples/tracepoints/tracepoint-probe-sample2.c | 44 | ||||
| -rw-r--r-- | samples/tracepoints/tracepoint-sample.c | 57 |
5 files changed, 0 insertions, 175 deletions
diff --git a/samples/tracepoints/Makefile b/samples/tracepoints/Makefile deleted file mode 100644 index 36479ad9ae14..000000000000 --- a/samples/tracepoints/Makefile +++ /dev/null | |||
| @@ -1,6 +0,0 @@ | |||
| 1 | # builds the tracepoint example kernel modules; | ||
| 2 | # then to use one (as root): insmod <module_name.ko> | ||
| 3 | |||
| 4 | obj-$(CONFIG_SAMPLE_TRACEPOINTS) += tracepoint-sample.o | ||
| 5 | obj-$(CONFIG_SAMPLE_TRACEPOINTS) += tracepoint-probe-sample.o | ||
| 6 | obj-$(CONFIG_SAMPLE_TRACEPOINTS) += tracepoint-probe-sample2.o | ||
diff --git a/samples/tracepoints/tp-samples-trace.h b/samples/tracepoints/tp-samples-trace.h deleted file mode 100644 index 4d46be965961..000000000000 --- a/samples/tracepoints/tp-samples-trace.h +++ /dev/null | |||
| @@ -1,11 +0,0 @@ | |||
| 1 | #ifndef _TP_SAMPLES_TRACE_H | ||
| 2 | #define _TP_SAMPLES_TRACE_H | ||
| 3 | |||
| 4 | #include <linux/proc_fs.h> /* for struct inode and struct file */ | ||
| 5 | #include <linux/tracepoint.h> | ||
| 6 | |||
| 7 | DECLARE_TRACE(subsys_event, | ||
| 8 | TP_PROTO(struct inode *inode, struct file *file), | ||
| 9 | TP_ARGS(inode, file)); | ||
| 10 | DECLARE_TRACE_NOARGS(subsys_eventb); | ||
| 11 | #endif | ||
diff --git a/samples/tracepoints/tracepoint-probe-sample.c b/samples/tracepoints/tracepoint-probe-sample.c deleted file mode 100644 index 744c0b9652a7..000000000000 --- a/samples/tracepoints/tracepoint-probe-sample.c +++ /dev/null | |||
| @@ -1,57 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * tracepoint-probe-sample.c | ||
| 3 | * | ||
| 4 | * sample tracepoint probes. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <linux/module.h> | ||
| 8 | #include <linux/file.h> | ||
| 9 | #include <linux/dcache.h> | ||
| 10 | #include "tp-samples-trace.h" | ||
| 11 | |||
| 12 | /* | ||
| 13 | * Here the caller only guarantees locking for struct file and struct inode. | ||
| 14 | * Locking must therefore be done in the probe to use the dentry. | ||
| 15 | */ | ||
| 16 | static void probe_subsys_event(void *ignore, | ||
| 17 | struct inode *inode, struct file *file) | ||
| 18 | { | ||
| 19 | path_get(&file->f_path); | ||
| 20 | dget(file->f_path.dentry); | ||
| 21 | printk(KERN_INFO "Event is encountered with filename %s\n", | ||
| 22 | file->f_path.dentry->d_name.name); | ||
| 23 | dput(file->f_path.dentry); | ||
| 24 | path_put(&file->f_path); | ||
| 25 | } | ||
| 26 | |||
| 27 | static void probe_subsys_eventb(void *ignore) | ||
| 28 | { | ||
| 29 | printk(KERN_INFO "Event B is encountered\n"); | ||
| 30 | } | ||
| 31 | |||
| 32 | static int __init tp_sample_trace_init(void) | ||
| 33 | { | ||
| 34 | int ret; | ||
| 35 | |||
| 36 | ret = register_trace_subsys_event(probe_subsys_event, NULL); | ||
| 37 | WARN_ON(ret); | ||
| 38 | ret = register_trace_subsys_eventb(probe_subsys_eventb, NULL); | ||
| 39 | WARN_ON(ret); | ||
| 40 | |||
| 41 | return 0; | ||
| 42 | } | ||
| 43 | |||
| 44 | module_init(tp_sample_trace_init); | ||
| 45 | |||
| 46 | static void __exit tp_sample_trace_exit(void) | ||
| 47 | { | ||
| 48 | unregister_trace_subsys_eventb(probe_subsys_eventb, NULL); | ||
| 49 | unregister_trace_subsys_event(probe_subsys_event, NULL); | ||
| 50 | tracepoint_synchronize_unregister(); | ||
| 51 | } | ||
| 52 | |||
| 53 | module_exit(tp_sample_trace_exit); | ||
| 54 | |||
| 55 | MODULE_LICENSE("GPL"); | ||
| 56 | MODULE_AUTHOR("Mathieu Desnoyers"); | ||
| 57 | MODULE_DESCRIPTION("Tracepoint Probes Samples"); | ||
diff --git a/samples/tracepoints/tracepoint-probe-sample2.c b/samples/tracepoints/tracepoint-probe-sample2.c deleted file mode 100644 index 9fcf990e5d4b..000000000000 --- a/samples/tracepoints/tracepoint-probe-sample2.c +++ /dev/null | |||
| @@ -1,44 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * tracepoint-probe-sample2.c | ||
| 3 | * | ||
| 4 | * 2nd sample tracepoint probes. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <linux/module.h> | ||
| 8 | #include <linux/fs.h> | ||
| 9 | #include "tp-samples-trace.h" | ||
| 10 | |||
| 11 | /* | ||
| 12 | * Here the caller only guarantees locking for struct file and struct inode. | ||
| 13 | * Locking must therefore be done in the probe to use the dentry. | ||
| 14 | */ | ||
| 15 | static void probe_subsys_event(void *ignore, | ||
| 16 | struct inode *inode, struct file *file) | ||
| 17 | { | ||
| 18 | printk(KERN_INFO "Event is encountered with inode number %lu\n", | ||
| 19 | inode->i_ino); | ||
| 20 | } | ||
| 21 | |||
| 22 | static int __init tp_sample_trace_init(void) | ||
| 23 | { | ||
| 24 | int ret; | ||
| 25 | |||
| 26 | ret = register_trace_subsys_event(probe_subsys_event, NULL); | ||
| 27 | WARN_ON(ret); | ||
| 28 | |||
| 29 | return 0; | ||
| 30 | } | ||
| 31 | |||
| 32 | module_init(tp_sample_trace_init); | ||
| 33 | |||
| 34 | static void __exit tp_sample_trace_exit(void) | ||
| 35 | { | ||
| 36 | unregister_trace_subsys_event(probe_subsys_event, NULL); | ||
| 37 | tracepoint_synchronize_unregister(); | ||
| 38 | } | ||
| 39 | |||
| 40 | module_exit(tp_sample_trace_exit); | ||
| 41 | |||
| 42 | MODULE_LICENSE("GPL"); | ||
| 43 | MODULE_AUTHOR("Mathieu Desnoyers"); | ||
| 44 | MODULE_DESCRIPTION("Tracepoint Probes Samples"); | ||
diff --git a/samples/tracepoints/tracepoint-sample.c b/samples/tracepoints/tracepoint-sample.c deleted file mode 100644 index f4d89e008c32..000000000000 --- a/samples/tracepoints/tracepoint-sample.c +++ /dev/null | |||
| @@ -1,57 +0,0 @@ | |||
| 1 | /* tracepoint-sample.c | ||
| 2 | * | ||
| 3 | * Executes a tracepoint when /proc/tracepoint-sample 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/sched.h> | ||
| 13 | #include <linux/proc_fs.h> | ||
| 14 | #include "tp-samples-trace.h" | ||
| 15 | |||
| 16 | DEFINE_TRACE(subsys_event); | ||
| 17 | DEFINE_TRACE(subsys_eventb); | ||
| 18 | |||
| 19 | struct proc_dir_entry *pentry_sample; | ||
| 20 | |||
| 21 | static int my_open(struct inode *inode, struct file *file) | ||
| 22 | { | ||
| 23 | int i; | ||
| 24 | |||
| 25 | trace_subsys_event(inode, file); | ||
| 26 | for (i = 0; i < 10; i++) | ||
| 27 | trace_subsys_eventb(); | ||
| 28 | return -EPERM; | ||
| 29 | } | ||
| 30 | |||
| 31 | static const struct file_operations mark_ops = { | ||
| 32 | .open = my_open, | ||
| 33 | .llseek = noop_llseek, | ||
| 34 | }; | ||
| 35 | |||
| 36 | static int __init sample_init(void) | ||
| 37 | { | ||
| 38 | printk(KERN_ALERT "sample init\n"); | ||
| 39 | pentry_sample = proc_create("tracepoint-sample", 0444, NULL, | ||
| 40 | &mark_ops); | ||
| 41 | if (!pentry_sample) | ||
| 42 | return -EPERM; | ||
| 43 | return 0; | ||
| 44 | } | ||
| 45 | |||
| 46 | static void __exit sample_exit(void) | ||
| 47 | { | ||
| 48 | printk(KERN_ALERT "sample exit\n"); | ||
| 49 | remove_proc_entry("tracepoint-sample", NULL); | ||
| 50 | } | ||
| 51 | |||
| 52 | module_init(sample_init) | ||
| 53 | module_exit(sample_exit) | ||
| 54 | |||
| 55 | MODULE_LICENSE("GPL"); | ||
| 56 | MODULE_AUTHOR("Mathieu Desnoyers"); | ||
| 57 | MODULE_DESCRIPTION("Tracepoint sample"); | ||
