History

tracing: Use flags instead of bool in trigger structure

gcc isn't known for handling bool in structures. Instead of using bool, use an integer mask and use bit flags instead.

Steven Rostedt (Red Hat) committed 10 years ago

Commit 353206f1 parent a88e1cf2 files · +49 −30Browse files

Unified · Split

2 files
  1. kernel/trace/trace.h +45 −26
  2. kernel/trace/trace_events_trigger.c +4 −4
kernel/trace/trace.h+45−26
@@ -1273,30 +1273,7 @@ struct event_trigger_ops { · 1272 unmodified lines
1273 * values are defined by adding new values to the trigger_type1273 * values are defined by adding new values to the trigger_type
1274 * enum in include/linux/trace_events.h.1274 * enum in include/linux/trace_events.h.
1275 *1275 *
1276 * @post_trigger: A flag that says whether or not this command needs1276 * @flags: See the enum event_command_flags below.
1277 * to have its action delayed until after the current event has
1278 * been closed. Some triggers need to avoid being invoked while
1279 * an event is currently in the process of being logged, since
1280 * the trigger may itself log data into the trace buffer. Thus
1281 * we make sure the current event is committed before invoking
1282 * those triggers. To do that, the trigger invocation is split
1283 * in two - the first part checks the filter using the current
1284 * trace record; if a command has the @post_trigger flag set, it
1285 * sets a bit for itself in the return value, otherwise it
1286 * directly invokes the trigger. Once all commands have been
1287 * either invoked or set their return flag, the current record is
1288 * either committed or discarded. At that point, if any commands
1289 * have deferred their triggers, those commands are finally
1290 * invoked following the close of the current event. In other
1291 * words, if the event_trigger_ops @func() probe implementation
1292 * itself logs to the trace buffer, this flag should be set,
1293 * otherwise it can be left unspecified.
1294 *
1295 * @needs_rec: A flag that says whether or not this command needs
1296 * access to the trace record in order to perform its function,
1297 * regardless of whether or not it has a filter associated with
1298 * it (filters make a trigger require access to the trace record
1299 * but are not always present).
1300 *1277 *
1301 * All the methods below, except for @set_filter() and @unreg_all(),1278 * All the methods below, except for @set_filter() and @unreg_all(),
1302 * must be implemented.1279 * must be implemented.
@@ -1341,8 +1318,7 @@ struct event_command { · 38 unmodified lines
1341 struct list_head list;1318 struct list_head list;
1342 char *name;1319 char *name;
1343 enum event_trigger_type trigger_type;1320 enum event_trigger_type trigger_type;
1344 bool post_trigger;1321 int flags;
1345 bool needs_rec;
1346 int (*func)(struct event_command *cmd_ops,1322 int (*func)(struct event_command *cmd_ops,
1347 struct trace_event_file *file,1323 struct trace_event_file *file,
1348 char *glob, char *cmd, char *params);1324 char *glob, char *cmd, char *params);
@@ -1361,6 +1337,49 @@ struct event_command { · 12 unmodified lines
1361 struct event_trigger_ops *(*get_trigger_ops)(char *cmd, char *param);1337 struct event_trigger_ops *(*get_trigger_ops)(char *cmd, char *param);
1362};1338};
1363 1339
1340/**
1341 * enum event_command_flags - flags for struct event_command
1342 *
1343 * @POST_TRIGGER: A flag that says whether or not this command needs
1344 * to have its action delayed until after the current event has
1345 * been closed. Some triggers need to avoid being invoked while
1346 * an event is currently in the process of being logged, since
1347 * the trigger may itself log data into the trace buffer. Thus
1348 * we make sure the current event is committed before invoking
1349 * those triggers. To do that, the trigger invocation is split
1350 * in two - the first part checks the filter using the current
1351 * trace record; if a command has the @post_trigger flag set, it
1352 * sets a bit for itself in the return value, otherwise it
1353 * directly invokes the trigger. Once all commands have been
1354 * either invoked or set their return flag, the current record is
1355 * either committed or discarded. At that point, if any commands
1356 * have deferred their triggers, those commands are finally
1357 * invoked following the close of the current event. In other
1358 * words, if the event_trigger_ops @func() probe implementation
1359 * itself logs to the trace buffer, this flag should be set,
1360 * otherwise it can be left unspecified.
1361 *
1362 * @NEEDS_REC: A flag that says whether or not this command needs
1363 * access to the trace record in order to perform its function,
1364 * regardless of whether or not it has a filter associated with
1365 * it (filters make a trigger require access to the trace record
1366 * but are not always present).
1367 */
1368enum event_command_flags {
1369 EVENT_CMD_FL_POST_TRIGGER = 1,
1370 EVENT_CMD_FL_NEEDS_REC = 2,
1371};
1372
1373static inline bool event_command_post_trigger(struct event_command *cmd_ops)
1374{
1375 return cmd_ops->flags & EVENT_CMD_FL_POST_TRIGGER;
1376}
1377
1378static inline bool event_command_needs_rec(struct event_command *cmd_ops)
1379{
1380 return cmd_ops->flags & EVENT_CMD_FL_NEEDS_REC;
1381}
1382
1364extern int trace_event_enable_disable(struct trace_event_file *file,1383extern int trace_event_enable_disable(struct trace_event_file *file,
1365 int enable, int soft_disable);1384 int enable, int soft_disable);
1366extern int tracing_alloc_snapshot(void);1385extern int tracing_alloc_snapshot(void);
kernel/trace/trace_events_trigger.c+4−4
@@ -81,7 +81,7 @@ event_triggers_call(struct trace_event_file *file, void *rec) · 80 unmodified lines
81 filter = rcu_dereference_sched(data->filter);81 filter = rcu_dereference_sched(data->filter);
82 if (filter && !filter_match_preds(filter, rec))82 if (filter && !filter_match_preds(filter, rec))
83 continue;83 continue;
84 if (data->cmd_ops->post_trigger) {84 if (event_command_post_trigger(data->cmd_ops)) {
85 tt |= data->cmd_ops->trigger_type;85 tt |= data->cmd_ops->trigger_type;
86 continue;86 continue;
87 }87 }
@@ -506,8 +506,8 @@ void update_cond_flag(struct trace_event_file *file) · 418 unmodified lines
506 bool set_cond = false;506 bool set_cond = false;
507 507
508 list_for_each_entry_rcu(data, &file->triggers, list) {508 list_for_each_entry_rcu(data, &file->triggers, list) {
509 if (data->filter || data->cmd_ops->post_trigger ||509 if (data->filter || event_command_post_trigger(data->cmd_ops) ||
510 data->cmd_ops->needs_rec) {510 event_command_needs_rec(data->cmd_ops)) {
511 set_cond = true;511 set_cond = true;
512 break;512 break;
513 }513 }
@@ -1035,7 +1035,7 @@ stacktrace_get_trigger_ops(char *cmd, char *param) · 521 unmodified lines
1035static struct event_command trigger_stacktrace_cmd = {1035static struct event_command trigger_stacktrace_cmd = {
1036 .name = "stacktrace",1036 .name = "stacktrace",
1037 .trigger_type = ETT_STACKTRACE,1037 .trigger_type = ETT_STACKTRACE,
1038 .post_trigger = true,1038 .flags = EVENT_CMD_FL_POST_TRIGGER,
1039 .func = event_trigger_callback,1039 .func = event_trigger_callback,
1040 .reg = register_trigger,1040 .reg = register_trigger,
1041 .unreg = unregister_trigger,1041 .unreg = unregister_trigger,