diff options
Diffstat (limited to 'kernel/trace/trace.h')
-rw-r--r-- | kernel/trace/trace.h | 193 |
1 files changed, 193 insertions, 0 deletions
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index ea189e027b80..02b592f2d4b7 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
@@ -1,3 +1,4 @@ | |||
1 | |||
1 | #ifndef _LINUX_KERNEL_TRACE_H | 2 | #ifndef _LINUX_KERNEL_TRACE_H |
2 | #define _LINUX_KERNEL_TRACE_H | 3 | #define _LINUX_KERNEL_TRACE_H |
3 | 4 | ||
@@ -587,6 +588,8 @@ void tracing_start_sched_switch_record(void); | |||
587 | int register_tracer(struct tracer *type); | 588 | int register_tracer(struct tracer *type); |
588 | int is_tracing_stopped(void); | 589 | int is_tracing_stopped(void); |
589 | 590 | ||
591 | loff_t tracing_lseek(struct file *file, loff_t offset, int whence); | ||
592 | |||
590 | extern cpumask_var_t __read_mostly tracing_buffer_mask; | 593 | extern cpumask_var_t __read_mostly tracing_buffer_mask; |
591 | 594 | ||
592 | #define for_each_tracing_cpu(cpu) \ | 595 | #define for_each_tracing_cpu(cpu) \ |
@@ -1020,6 +1023,10 @@ extern int apply_subsystem_event_filter(struct ftrace_subsystem_dir *dir, | |||
1020 | extern void print_subsystem_event_filter(struct event_subsystem *system, | 1023 | extern void print_subsystem_event_filter(struct event_subsystem *system, |
1021 | struct trace_seq *s); | 1024 | struct trace_seq *s); |
1022 | extern int filter_assign_type(const char *type); | 1025 | extern int filter_assign_type(const char *type); |
1026 | extern int create_event_filter(struct ftrace_event_call *call, | ||
1027 | char *filter_str, bool set_str, | ||
1028 | struct event_filter **filterp); | ||
1029 | extern void free_event_filter(struct event_filter *filter); | ||
1023 | 1030 | ||
1024 | struct ftrace_event_field * | 1031 | struct ftrace_event_field * |
1025 | trace_find_event_field(struct ftrace_event_call *call, char *name); | 1032 | trace_find_event_field(struct ftrace_event_call *call, char *name); |
@@ -1028,9 +1035,195 @@ extern void trace_event_enable_cmd_record(bool enable); | |||
1028 | extern int event_trace_add_tracer(struct dentry *parent, struct trace_array *tr); | 1035 | extern int event_trace_add_tracer(struct dentry *parent, struct trace_array *tr); |
1029 | extern int event_trace_del_tracer(struct trace_array *tr); | 1036 | extern int event_trace_del_tracer(struct trace_array *tr); |
1030 | 1037 | ||
1038 | extern struct ftrace_event_file *find_event_file(struct trace_array *tr, | ||
1039 | const char *system, | ||
1040 | const char *event); | ||
1041 | |||
1042 | static inline void *event_file_data(struct file *filp) | ||
1043 | { | ||
1044 | return ACCESS_ONCE(file_inode(filp)->i_private); | ||
1045 | } | ||
1046 | |||
1031 | extern struct mutex event_mutex; | 1047 | extern struct mutex event_mutex; |
1032 | extern struct list_head ftrace_events; | 1048 | extern struct list_head ftrace_events; |
1033 | 1049 | ||
1050 | extern const struct file_operations event_trigger_fops; | ||
1051 | |||
1052 | extern int register_trigger_cmds(void); | ||
1053 | extern void clear_event_triggers(struct trace_array *tr); | ||
1054 | |||
1055 | struct event_trigger_data { | ||
1056 | unsigned long count; | ||
1057 | int ref; | ||
1058 | struct event_trigger_ops *ops; | ||
1059 | struct event_command *cmd_ops; | ||
1060 | struct event_filter __rcu *filter; | ||
1061 | char *filter_str; | ||
1062 | void *private_data; | ||
1063 | struct list_head list; | ||
1064 | }; | ||
1065 | |||
1066 | /** | ||
1067 | * struct event_trigger_ops - callbacks for trace event triggers | ||
1068 | * | ||
1069 | * The methods in this structure provide per-event trigger hooks for | ||
1070 | * various trigger operations. | ||
1071 | * | ||
1072 | * All the methods below, except for @init() and @free(), must be | ||
1073 | * implemented. | ||
1074 | * | ||
1075 | * @func: The trigger 'probe' function called when the triggering | ||
1076 | * event occurs. The data passed into this callback is the data | ||
1077 | * that was supplied to the event_command @reg() function that | ||
1078 | * registered the trigger (see struct event_command). | ||
1079 | * | ||
1080 | * @init: An optional initialization function called for the trigger | ||
1081 | * when the trigger is registered (via the event_command reg() | ||
1082 | * function). This can be used to perform per-trigger | ||
1083 | * initialization such as incrementing a per-trigger reference | ||
1084 | * count, for instance. This is usually implemented by the | ||
1085 | * generic utility function @event_trigger_init() (see | ||
1086 | * trace_event_triggers.c). | ||
1087 | * | ||
1088 | * @free: An optional de-initialization function called for the | ||
1089 | * trigger when the trigger is unregistered (via the | ||
1090 | * event_command @reg() function). This can be used to perform | ||
1091 | * per-trigger de-initialization such as decrementing a | ||
1092 | * per-trigger reference count and freeing corresponding trigger | ||
1093 | * data, for instance. This is usually implemented by the | ||
1094 | * generic utility function @event_trigger_free() (see | ||
1095 | * trace_event_triggers.c). | ||
1096 | * | ||
1097 | * @print: The callback function invoked to have the trigger print | ||
1098 | * itself. This is usually implemented by a wrapper function | ||
1099 | * that calls the generic utility function @event_trigger_print() | ||
1100 | * (see trace_event_triggers.c). | ||
1101 | */ | ||
1102 | struct event_trigger_ops { | ||
1103 | void (*func)(struct event_trigger_data *data); | ||
1104 | int (*init)(struct event_trigger_ops *ops, | ||
1105 | struct event_trigger_data *data); | ||
1106 | void (*free)(struct event_trigger_ops *ops, | ||
1107 | struct event_trigger_data *data); | ||
1108 | int (*print)(struct seq_file *m, | ||
1109 | struct event_trigger_ops *ops, | ||
1110 | struct event_trigger_data *data); | ||
1111 | }; | ||
1112 | |||
1113 | /** | ||
1114 | * struct event_command - callbacks and data members for event commands | ||
1115 | * | ||
1116 | * Event commands are invoked by users by writing the command name | ||
1117 | * into the 'trigger' file associated with a trace event. The | ||
1118 | * parameters associated with a specific invocation of an event | ||
1119 | * command are used to create an event trigger instance, which is | ||
1120 | * added to the list of trigger instances associated with that trace | ||
1121 | * event. When the event is hit, the set of triggers associated with | ||
1122 | * that event is invoked. | ||
1123 | * | ||
1124 | * The data members in this structure provide per-event command data | ||
1125 | * for various event commands. | ||
1126 | * | ||
1127 | * All the data members below, except for @post_trigger, must be set | ||
1128 | * for each event command. | ||
1129 | * | ||
1130 | * @name: The unique name that identifies the event command. This is | ||
1131 | * the name used when setting triggers via trigger files. | ||
1132 | * | ||
1133 | * @trigger_type: A unique id that identifies the event command | ||
1134 | * 'type'. This value has two purposes, the first to ensure that | ||
1135 | * only one trigger of the same type can be set at a given time | ||
1136 | * for a particular event e.g. it doesn't make sense to have both | ||
1137 | * a traceon and traceoff trigger attached to a single event at | ||
1138 | * the same time, so traceon and traceoff have the same type | ||
1139 | * though they have different names. The @trigger_type value is | ||
1140 | * also used as a bit value for deferring the actual trigger | ||
1141 | * action until after the current event is finished. Some | ||
1142 | * commands need to do this if they themselves log to the trace | ||
1143 | * buffer (see the @post_trigger() member below). @trigger_type | ||
1144 | * values are defined by adding new values to the trigger_type | ||
1145 | * enum in include/linux/ftrace_event.h. | ||
1146 | * | ||
1147 | * @post_trigger: A flag that says whether or not this command needs | ||
1148 | * to have its action delayed until after the current event has | ||
1149 | * been closed. Some triggers need to avoid being invoked while | ||
1150 | * an event is currently in the process of being logged, since | ||
1151 | * the trigger may itself log data into the trace buffer. Thus | ||
1152 | * we make sure the current event is committed before invoking | ||
1153 | * those triggers. To do that, the trigger invocation is split | ||
1154 | * in two - the first part checks the filter using the current | ||
1155 | * trace record; if a command has the @post_trigger flag set, it | ||
1156 | * sets a bit for itself in the return value, otherwise it | ||
1157 | * directly invokes the trigger. Once all commands have been | ||
1158 | * either invoked or set their return flag, the current record is | ||
1159 | * either committed or discarded. At that point, if any commands | ||
1160 | * have deferred their triggers, those commands are finally | ||
1161 | * invoked following the close of the current event. In other | ||
1162 | * words, if the event_trigger_ops @func() probe implementation | ||
1163 | * itself logs to the trace buffer, this flag should be set, | ||
1164 | * otherwise it can be left unspecified. | ||
1165 | * | ||
1166 | * All the methods below, except for @set_filter(), must be | ||
1167 | * implemented. | ||
1168 | * | ||
1169 | * @func: The callback function responsible for parsing and | ||
1170 | * registering the trigger written to the 'trigger' file by the | ||
1171 | * user. It allocates the trigger instance and registers it with | ||
1172 | * the appropriate trace event. It makes use of the other | ||
1173 | * event_command callback functions to orchestrate this, and is | ||
1174 | * usually implemented by the generic utility function | ||
1175 | * @event_trigger_callback() (see trace_event_triggers.c). | ||
1176 | * | ||
1177 | * @reg: Adds the trigger to the list of triggers associated with the | ||
1178 | * event, and enables the event trigger itself, after | ||
1179 | * initializing it (via the event_trigger_ops @init() function). | ||
1180 | * This is also where commands can use the @trigger_type value to | ||
1181 | * make the decision as to whether or not multiple instances of | ||
1182 | * the trigger should be allowed. This is usually implemented by | ||
1183 | * the generic utility function @register_trigger() (see | ||
1184 | * trace_event_triggers.c). | ||
1185 | * | ||
1186 | * @unreg: Removes the trigger from the list of triggers associated | ||
1187 | * with the event, and disables the event trigger itself, after | ||
1188 | * initializing it (via the event_trigger_ops @free() function). | ||
1189 | * This is usually implemented by the generic utility function | ||
1190 | * @unregister_trigger() (see trace_event_triggers.c). | ||
1191 | * | ||
1192 | * @set_filter: An optional function called to parse and set a filter | ||
1193 | * for the trigger. If no @set_filter() method is set for the | ||
1194 | * event command, filters set by the user for the command will be | ||
1195 | * ignored. This is usually implemented by the generic utility | ||
1196 | * function @set_trigger_filter() (see trace_event_triggers.c). | ||
1197 | * | ||
1198 | * @get_trigger_ops: The callback function invoked to retrieve the | ||
1199 | * event_trigger_ops implementation associated with the command. | ||
1200 | */ | ||
1201 | struct event_command { | ||
1202 | struct list_head list; | ||
1203 | char *name; | ||
1204 | enum event_trigger_type trigger_type; | ||
1205 | bool post_trigger; | ||
1206 | int (*func)(struct event_command *cmd_ops, | ||
1207 | struct ftrace_event_file *file, | ||
1208 | char *glob, char *cmd, char *params); | ||
1209 | int (*reg)(char *glob, | ||
1210 | struct event_trigger_ops *ops, | ||
1211 | struct event_trigger_data *data, | ||
1212 | struct ftrace_event_file *file); | ||
1213 | void (*unreg)(char *glob, | ||
1214 | struct event_trigger_ops *ops, | ||
1215 | struct event_trigger_data *data, | ||
1216 | struct ftrace_event_file *file); | ||
1217 | int (*set_filter)(char *filter_str, | ||
1218 | struct event_trigger_data *data, | ||
1219 | struct ftrace_event_file *file); | ||
1220 | struct event_trigger_ops *(*get_trigger_ops)(char *cmd, char *param); | ||
1221 | }; | ||
1222 | |||
1223 | extern int trace_event_enable_disable(struct ftrace_event_file *file, | ||
1224 | int enable, int soft_disable); | ||
1225 | extern int tracing_alloc_snapshot(void); | ||
1226 | |||
1034 | extern const char *__start___trace_bprintk_fmt[]; | 1227 | extern const char *__start___trace_bprintk_fmt[]; |
1035 | extern const char *__stop___trace_bprintk_fmt[]; | 1228 | extern const char *__stop___trace_bprintk_fmt[]; |
1036 | 1229 | ||