Commit d75f717e19fe595e7efbf67de195ada8d89dfbbe

Authored by Steven Rostedt
Committed by Steven Rostedt
1 parent b736f48bda

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>

Showing 7 changed files with 1 additions and 182 deletions Side-by-side Diff

... ... @@ -5,12 +5,6 @@
5 5  
6 6 if SAMPLES
7 7  
8   -config SAMPLE_TRACEPOINTS
9   - tristate "Build tracepoints examples -- loadable modules only"
10   - depends on TRACEPOINTS && m
11   - help
12   - This build tracepoints example modules.
13   -
14 8 config SAMPLE_TRACE_EVENTS
15 9 tristate "Build trace_events examples -- loadable modules only"
16 10 depends on EVENT_TRACING && m
1 1 # Makefile for Linux samples code
2 2  
3   -obj-$(CONFIG_SAMPLES) += kobject/ kprobes/ tracepoints/ trace_events/ \
  3 +obj-$(CONFIG_SAMPLES) += kobject/ kprobes/ trace_events/ \
4 4 hw_breakpoint/ kfifo/ kdb/ hidraw/ rpmsg/ seccomp/
samples/tracepoints/Makefile
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
samples/tracepoints/tp-samples-trace.h
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
samples/tracepoints/tracepoint-probe-sample.c
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");
samples/tracepoints/tracepoint-probe-sample2.c
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");
samples/tracepoints/tracepoint-sample.c
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");