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

Showing the changes to kernel/trace (2 of 2 files). Show all

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
12731273 * values are defined by adding new values to the trigger_type
12741274 * enum in include/linux/trace_events.h.
12751275 *
1276− * @post_trigger: A flag that says whether or not this command needs
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).
1276+ * @flags: See the enum event_command_flags below.
13001277 *
13011278 * All the methods below, except for @set_filter() and @unreg_all(),
13021279 * must be implemented.
@@ -1341,8 +1318,7 @@ struct event_command { · 38 unmodified lines
13411318 struct list_head list;
13421319 char *name;
13431320 enum event_trigger_type trigger_type;
1344− bool post_trigger;
1345− bool needs_rec;
1321+ int flags;
13461322 int (*func)(struct event_command *cmd_ops,
13471323 struct trace_event_file *file,
13481324 char *glob, char *cmd, char *params);
@@ -1361,6 +1337,49 @@ struct event_command { · 12 unmodified lines
13611337 struct event_trigger_ops *(*get_trigger_ops)(char *cmd, char *param);
13621338 };
13631339
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+ */
1368+enum event_command_flags {
1369+ EVENT_CMD_FL_POST_TRIGGER = 1,
1370+ EVENT_CMD_FL_NEEDS_REC = 2,
1371+};
1372+
1373+static inline bool event_command_post_trigger(struct event_command *cmd_ops)
1374+{
1375+ return cmd_ops->flags & EVENT_CMD_FL_POST_TRIGGER;
1376+}
1377+
1378+static inline bool event_command_needs_rec(struct event_command *cmd_ops)
1379+{
1380+ return cmd_ops->flags & EVENT_CMD_FL_NEEDS_REC;
1381+}
1382+
13641383 extern int trace_event_enable_disable(struct trace_event_file *file,
13651384 int enable, int soft_disable);
13661385 extern 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
8181 filter = rcu_dereference_sched(data->filter);
8282 if (filter && !filter_match_preds(filter, rec))
8383 continue;
84− if (data->cmd_ops->post_trigger) {
84+ if (event_command_post_trigger(data->cmd_ops)) {
8585 tt |= data->cmd_ops->trigger_type;
8686 continue;
8787 }
@@ -506,8 +506,8 @@ void update_cond_flag(struct trace_event_file *file) · 418 unmodified lines
506506 bool set_cond = false;
507507
508508 list_for_each_entry_rcu(data, &file->triggers, list) {
509− if (data->filter || data->cmd_ops->post_trigger ||
510− data->cmd_ops->needs_rec) {
509+ if (data->filter || event_command_post_trigger(data->cmd_ops) ||
510+ event_command_needs_rec(data->cmd_ops)) {
511511 set_cond = true;
512512 break;
513513 }
@@ -1035,7 +1035,7 @@ stacktrace_get_trigger_ops(char *cmd, char *param) · 521 unmodified lines
10351035 static struct event_command trigger_stacktrace_cmd = {
10361036 .name = "stacktrace",
10371037 .trigger_type = ETT_STACKTRACE,
1038− .post_trigger = true,
1038+ .flags = EVENT_CMD_FL_POST_TRIGGER,
10391039 .func = event_trigger_callback,
10401040 .reg = register_trigger,
10411041 .unreg = unregister_trigger,