aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2009-04-13 11:20:49 -0400
committerSteven Rostedt <rostedt@goodmis.org>2009-04-14 12:57:58 -0400
commit97f2025153499faa17267a0d4e18c7afaf73f39d (patch)
treecd3ea51a93093ea5250ef38b4b5bf6c2aa3f9ed5
parent9504504cbab29ecb694186b1c5b15d3579c43c51 (diff)
tracing/events: move declarations from trace directory to core include
In preparation to allowing trace events to happen in modules, we need to move some of the local declarations in the kernel/trace directory into include/linux. This patch simply moves the declarations and performs no context changes. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--include/linux/ftrace_event.h146
-rw-r--r--kernel/trace/trace.h120
-rw-r--r--kernel/trace/trace_output.h14
3 files changed, 147 insertions, 133 deletions
diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
new file mode 100644
index 000000000000..496b76d9f9d8
--- /dev/null
+++ b/include/linux/ftrace_event.h
@@ -0,0 +1,146 @@
1#ifndef _LINUX_FTRACE_EVENT_H
2#define _LINUX_FTRACE_EVENT_H
3
4#include <linux/trace_seq.h>
5#include <linux/ring_buffer.h>
6
7
8struct trace_array;
9struct tracer;
10
11/*
12 * The trace entry - the most basic unit of tracing. This is what
13 * is printed in the end as a single line in the trace output, such as:
14 *
15 * bash-15816 [01] 235.197585: idle_cpu <- irq_enter
16 */
17struct trace_entry {
18 unsigned char type;
19 unsigned char flags;
20 unsigned char preempt_count;
21 int pid;
22 int tgid;
23};
24
25/*
26 * Trace iterator - used by printout routines who present trace
27 * results to users and which routines might sleep, etc:
28 */
29struct trace_iterator {
30 struct trace_array *tr;
31 struct tracer *trace;
32 void *private;
33 int cpu_file;
34 struct mutex mutex;
35 struct ring_buffer_iter *buffer_iter[NR_CPUS];
36
37 /* The below is zeroed out in pipe_read */
38 struct trace_seq seq;
39 struct trace_entry *ent;
40 int cpu;
41 u64 ts;
42
43 unsigned long iter_flags;
44 loff_t pos;
45 long idx;
46
47 cpumask_var_t started;
48};
49
50
51typedef enum print_line_t (*trace_print_func)(struct trace_iterator *iter,
52 int flags);
53struct trace_event {
54 struct hlist_node node;
55 int type;
56 trace_print_func trace;
57 trace_print_func raw;
58 trace_print_func hex;
59 trace_print_func binary;
60};
61
62extern int register_ftrace_event(struct trace_event *event);
63extern int unregister_ftrace_event(struct trace_event *event);
64
65/* Return values for print_line callback */
66enum print_line_t {
67 TRACE_TYPE_PARTIAL_LINE = 0, /* Retry after flushing the seq */
68 TRACE_TYPE_HANDLED = 1,
69 TRACE_TYPE_UNHANDLED = 2, /* Relay to other output functions */
70 TRACE_TYPE_NO_CONSUME = 3 /* Handled but ask to not consume */
71};
72
73
74struct ring_buffer_event *
75trace_current_buffer_lock_reserve(unsigned char type, unsigned long len,
76 unsigned long flags, int pc);
77void trace_current_buffer_unlock_commit(struct ring_buffer_event *event,
78 unsigned long flags, int pc);
79void trace_nowake_buffer_unlock_commit(struct ring_buffer_event *event,
80 unsigned long flags, int pc);
81void trace_current_buffer_discard_commit(struct ring_buffer_event *event);
82
83void tracing_record_cmdline(struct task_struct *tsk);
84
85struct ftrace_event_call {
86 char *name;
87 char *system;
88 struct dentry *dir;
89 int enabled;
90 int (*regfunc)(void);
91 void (*unregfunc)(void);
92 int id;
93 int (*raw_init)(void);
94 int (*show_format)(struct trace_seq *s);
95 int (*define_fields)(void);
96 struct list_head fields;
97 int n_preds;
98 struct filter_pred **preds;
99
100#ifdef CONFIG_EVENT_PROFILE
101 atomic_t profile_count;
102 int (*profile_enable)(struct ftrace_event_call *);
103 void (*profile_disable)(struct ftrace_event_call *);
104#endif
105};
106
107#define MAX_FILTER_PRED 8
108#define MAX_FILTER_STR_VAL 128
109
110extern int init_preds(struct ftrace_event_call *call);
111extern int filter_match_preds(struct ftrace_event_call *call, void *rec);
112extern int filter_current_check_discard(struct ftrace_event_call *call,
113 void *rec,
114 struct ring_buffer_event *event);
115
116extern int trace_define_field(struct ftrace_event_call *call, char *type,
117 char *name, int offset, int size);
118
119
120/*
121 * The double __builtin_constant_p is because gcc will give us an error
122 * if we try to allocate the static variable to fmt if it is not a
123 * constant. Even with the outer if statement optimizing out.
124 */
125#define event_trace_printk(ip, fmt, args...) \
126do { \
127 __trace_printk_check_format(fmt, ##args); \
128 tracing_record_cmdline(current); \
129 if (__builtin_constant_p(fmt)) { \
130 static const char *trace_printk_fmt \
131 __attribute__((section("__trace_printk_fmt"))) = \
132 __builtin_constant_p(fmt) ? fmt : NULL; \
133 \
134 __trace_bprintk(ip, trace_printk_fmt, ##args); \
135 } else \
136 __trace_printk(ip, fmt, ##args); \
137} while (0)
138
139#define __common_field(type, item) \
140 ret = trace_define_field(event_call, #type, "common_" #item, \
141 offsetof(typeof(field.ent), item), \
142 sizeof(field.ent.item)); \
143 if (ret) \
144 return ret;
145
146#endif /* _LINUX_FTRACE_EVENT_H */
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 1882846b7389..6bcdf4af9b2d 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -13,6 +13,7 @@
13#include <trace/power.h> 13#include <trace/power.h>
14 14
15#include <linux/trace_seq.h> 15#include <linux/trace_seq.h>
16#include <linux/ftrace_event.h>
16 17
17enum trace_type { 18enum trace_type {
18 __TRACE_FIRST_TYPE = 0, 19 __TRACE_FIRST_TYPE = 0,
@@ -44,20 +45,6 @@ enum trace_type {
44}; 45};
45 46
46/* 47/*
47 * The trace entry - the most basic unit of tracing. This is what
48 * is printed in the end as a single line in the trace output, such as:
49 *
50 * bash-15816 [01] 235.197585: idle_cpu <- irq_enter
51 */
52struct trace_entry {
53 unsigned char type;
54 unsigned char flags;
55 unsigned char preempt_count;
56 int pid;
57 int tgid;
58};
59
60/*
61 * Function trace entry - function address and parent function addres: 48 * Function trace entry - function address and parent function addres:
62 */ 49 */
63struct ftrace_entry { 50struct ftrace_entry {
@@ -265,8 +252,6 @@ struct trace_array_cpu {
265 char comm[TASK_COMM_LEN]; 252 char comm[TASK_COMM_LEN];
266}; 253};
267 254
268struct trace_iterator;
269
270/* 255/*
271 * The trace array - an array of per-CPU trace arrays. This is the 256 * The trace array - an array of per-CPU trace arrays. This is the
272 * highest level data structure that individual tracers deal with. 257 * highest level data structure that individual tracers deal with.
@@ -341,15 +326,6 @@ extern void __ftrace_bad_type(void);
341 __ftrace_bad_type(); \ 326 __ftrace_bad_type(); \
342 } while (0) 327 } while (0)
343 328
344/* Return values for print_line callback */
345enum print_line_t {
346 TRACE_TYPE_PARTIAL_LINE = 0, /* Retry after flushing the seq */
347 TRACE_TYPE_HANDLED = 1,
348 TRACE_TYPE_UNHANDLED = 2, /* Relay to other output functions */
349 TRACE_TYPE_NO_CONSUME = 3 /* Handled but ask to not consume */
350};
351
352
353/* 329/*
354 * An option specific to a tracer. This is a boolean value. 330 * An option specific to a tracer. This is a boolean value.
355 * The bit is the bit index that sets its value on the 331 * The bit is the bit index that sets its value on the
@@ -428,31 +404,6 @@ struct tracer {
428 404
429#define TRACE_PIPE_ALL_CPU -1 405#define TRACE_PIPE_ALL_CPU -1
430 406
431/*
432 * Trace iterator - used by printout routines who present trace
433 * results to users and which routines might sleep, etc:
434 */
435struct trace_iterator {
436 struct trace_array *tr;
437 struct tracer *trace;
438 void *private;
439 int cpu_file;
440 struct mutex mutex;
441 struct ring_buffer_iter *buffer_iter[NR_CPUS];
442
443 /* The below is zeroed out in pipe_read */
444 struct trace_seq seq;
445 struct trace_entry *ent;
446 int cpu;
447 u64 ts;
448
449 unsigned long iter_flags;
450 loff_t pos;
451 long idx;
452
453 cpumask_var_t started;
454};
455
456int tracer_init(struct tracer *t, struct trace_array *tr); 407int tracer_init(struct tracer *t, struct trace_array *tr);
457int tracing_is_enabled(void); 408int tracing_is_enabled(void);
458void trace_wake_up(void); 409void trace_wake_up(void);
@@ -479,15 +430,6 @@ void trace_buffer_unlock_commit(struct trace_array *tr,
479 struct ring_buffer_event *event, 430 struct ring_buffer_event *event,
480 unsigned long flags, int pc); 431 unsigned long flags, int pc);
481 432
482struct ring_buffer_event *
483trace_current_buffer_lock_reserve(unsigned char type, unsigned long len,
484 unsigned long flags, int pc);
485void trace_current_buffer_unlock_commit(struct ring_buffer_event *event,
486 unsigned long flags, int pc);
487void trace_nowake_buffer_unlock_commit(struct ring_buffer_event *event,
488 unsigned long flags, int pc);
489void trace_current_buffer_discard_commit(struct ring_buffer_event *event);
490
491struct trace_entry *tracing_get_trace_entry(struct trace_array *tr, 433struct trace_entry *tracing_get_trace_entry(struct trace_array *tr,
492 struct trace_array_cpu *data); 434 struct trace_array_cpu *data);
493 435
@@ -510,7 +452,6 @@ void tracing_sched_switch_trace(struct trace_array *tr,
510 struct task_struct *prev, 452 struct task_struct *prev,
511 struct task_struct *next, 453 struct task_struct *next,
512 unsigned long flags, int pc); 454 unsigned long flags, int pc);
513void tracing_record_cmdline(struct task_struct *tsk);
514 455
515void tracing_sched_wakeup_trace(struct trace_array *tr, 456void tracing_sched_wakeup_trace(struct trace_array *tr,
516 struct task_struct *wakee, 457 struct task_struct *wakee,
@@ -790,28 +731,6 @@ struct ftrace_event_field {
790 int size; 731 int size;
791}; 732};
792 733
793struct ftrace_event_call {
794 char *name;
795 char *system;
796 struct dentry *dir;
797 int enabled;
798 int (*regfunc)(void);
799 void (*unregfunc)(void);
800 int id;
801 int (*raw_init)(void);
802 int (*show_format)(struct trace_seq *s);
803 int (*define_fields)(void);
804 struct list_head fields;
805 int n_preds;
806 struct filter_pred **preds;
807
808#ifdef CONFIG_EVENT_PROFILE
809 atomic_t profile_count;
810 int (*profile_enable)(struct ftrace_event_call *);
811 void (*profile_disable)(struct ftrace_event_call *);
812#endif
813};
814
815struct event_subsystem { 734struct event_subsystem {
816 struct list_head list; 735 struct list_head list;
817 const char *name; 736 const char *name;
@@ -825,9 +744,6 @@ struct event_subsystem {
825 (unsigned long)event < (unsigned long)__stop_ftrace_events; \ 744 (unsigned long)event < (unsigned long)__stop_ftrace_events; \
826 event++) 745 event++)
827 746
828#define MAX_FILTER_PRED 8
829#define MAX_FILTER_STR_VAL 128
830
831struct filter_pred; 747struct filter_pred;
832 748
833typedef int (*filter_pred_fn_t) (struct filter_pred *pred, void *event); 749typedef int (*filter_pred_fn_t) (struct filter_pred *pred, void *event);
@@ -845,9 +761,6 @@ struct filter_pred {
845 int clear; 761 int clear;
846}; 762};
847 763
848int trace_define_field(struct ftrace_event_call *call, char *type,
849 char *name, int offset, int size);
850extern int init_preds(struct ftrace_event_call *call);
851extern void filter_free_pred(struct filter_pred *pred); 764extern void filter_free_pred(struct filter_pred *pred);
852extern void filter_print_preds(struct filter_pred **preds, int n_preds, 765extern void filter_print_preds(struct filter_pred **preds, int n_preds,
853 struct trace_seq *s); 766 struct trace_seq *s);
@@ -855,13 +768,9 @@ extern int filter_parse(char **pbuf, struct filter_pred *pred);
855extern int filter_add_pred(struct ftrace_event_call *call, 768extern int filter_add_pred(struct ftrace_event_call *call,
856 struct filter_pred *pred); 769 struct filter_pred *pred);
857extern void filter_disable_preds(struct ftrace_event_call *call); 770extern void filter_disable_preds(struct ftrace_event_call *call);
858extern int filter_match_preds(struct ftrace_event_call *call, void *rec);
859extern void filter_free_subsystem_preds(struct event_subsystem *system); 771extern void filter_free_subsystem_preds(struct event_subsystem *system);
860extern int filter_add_subsystem_pred(struct event_subsystem *system, 772extern int filter_add_subsystem_pred(struct event_subsystem *system,
861 struct filter_pred *pred); 773 struct filter_pred *pred);
862extern int filter_current_check_discard(struct ftrace_event_call *call,
863 void *rec,
864 struct ring_buffer_event *event);
865 774
866static inline int 775static inline int
867filter_check_discard(struct ftrace_event_call *call, void *rec, 776filter_check_discard(struct ftrace_event_call *call, void *rec,
@@ -876,14 +785,6 @@ filter_check_discard(struct ftrace_event_call *call, void *rec,
876 return 0; 785 return 0;
877} 786}
878 787
879#define __common_field(type, item) \
880 ret = trace_define_field(event_call, #type, "common_" #item, \
881 offsetof(typeof(field.ent), item), \
882 sizeof(field.ent.item)); \
883 if (ret) \
884 return ret;
885
886void event_trace_printk(unsigned long ip, const char *fmt, ...);
887extern struct ftrace_event_call __start_ftrace_events[]; 788extern struct ftrace_event_call __start_ftrace_events[];
888extern struct ftrace_event_call __stop_ftrace_events[]; 789extern struct ftrace_event_call __stop_ftrace_events[];
889 790
@@ -895,25 +796,6 @@ extern struct ftrace_event_call __stop_ftrace_events[];
895extern const char *__start___trace_bprintk_fmt[]; 796extern const char *__start___trace_bprintk_fmt[];
896extern const char *__stop___trace_bprintk_fmt[]; 797extern const char *__stop___trace_bprintk_fmt[];
897 798
898/*
899 * The double __builtin_constant_p is because gcc will give us an error
900 * if we try to allocate the static variable to fmt if it is not a
901 * constant. Even with the outer if statement optimizing out.
902 */
903#define event_trace_printk(ip, fmt, args...) \
904do { \
905 __trace_printk_check_format(fmt, ##args); \
906 tracing_record_cmdline(current); \
907 if (__builtin_constant_p(fmt)) { \
908 static const char *trace_printk_fmt \
909 __attribute__((section("__trace_printk_fmt"))) = \
910 __builtin_constant_p(fmt) ? fmt : NULL; \
911 \
912 __trace_bprintk(ip, trace_printk_fmt, ##args); \
913 } else \
914 __trace_printk(ip, fmt, ##args); \
915} while (0)
916
917#undef TRACE_EVENT_FORMAT 799#undef TRACE_EVENT_FORMAT
918#define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \ 800#define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \
919 extern struct ftrace_event_call event_##call; 801 extern struct ftrace_event_call event_##call;
diff --git a/kernel/trace/trace_output.h b/kernel/trace/trace_output.h
index 5c7cbfb65c71..6e220a8e5706 100644
--- a/kernel/trace/trace_output.h
+++ b/kernel/trace/trace_output.h
@@ -4,18 +4,6 @@
4#include <linux/trace_seq.h> 4#include <linux/trace_seq.h>
5#include "trace.h" 5#include "trace.h"
6 6
7typedef enum print_line_t (*trace_print_func)(struct trace_iterator *iter,
8 int flags);
9
10struct trace_event {
11 struct hlist_node node;
12 int type;
13 trace_print_func trace;
14 trace_print_func raw;
15 trace_print_func hex;
16 trace_print_func binary;
17};
18
19extern enum print_line_t 7extern enum print_line_t
20trace_print_bprintk_msg_only(struct trace_iterator *iter); 8trace_print_bprintk_msg_only(struct trace_iterator *iter);
21extern enum print_line_t 9extern enum print_line_t
@@ -33,8 +21,6 @@ extern int trace_print_context(struct trace_iterator *iter);
33extern int trace_print_lat_context(struct trace_iterator *iter); 21extern int trace_print_lat_context(struct trace_iterator *iter);
34 22
35extern struct trace_event *ftrace_find_event(int type); 23extern struct trace_event *ftrace_find_event(int type);
36extern int register_ftrace_event(struct trace_event *event);
37extern int unregister_ftrace_event(struct trace_event *event);
38 24
39extern enum print_line_t trace_nop_print(struct trace_iterator *iter, 25extern enum print_line_t trace_nop_print(struct trace_iterator *iter,
40 int flags); 26 int flags);