Skip to content

Commit 8076559

Browse files
committed
tracing: Rewrite filter logic to be simpler and faster
Al Viro reviewed the filter logic of ftrace trace events and found it to be very troubling. It creates a binary tree based on the logic operators and walks it during tracing. He sent myself and Tom Zanussi a long explanation (and formal proof) of how to do the string parsing better and end up with a program array that can be simply iterated to come up with the correct results. I took his ideas and his pseudo code and rewrote the filter logic based on them. In doing so, I was able to remove a lot of code, and have a much more condensed filter logic in the process. I wrote a very long comment describing the methadology that Al proposed in my own words. For more info on how this works, read the comment above predicate_parse(). Suggested-by: Al Viro <viro@ZenIV.linux.org.uk> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
1 parent 478325f commit 8076559

File tree

2 files changed

+1054
-1272
lines changed

2 files changed

+1054
-1272
lines changed

kernel/trace/trace.h

+5-10
Original file line numberDiff line numberDiff line change
@@ -1216,12 +1216,11 @@ struct ftrace_event_field {
12161216
int is_signed;
12171217
};
12181218

1219+
struct prog_entry;
1220+
12191221
struct event_filter {
1220-
int n_preds; /* Number assigned */
1221-
int a_preds; /* allocated */
1222-
struct filter_pred __rcu *preds;
1223-
struct filter_pred __rcu *root;
1224-
char *filter_string;
1222+
struct prog_entry __rcu *prog;
1223+
char *filter_string;
12251224
};
12261225

12271226
struct event_subsystem {
@@ -1413,12 +1412,8 @@ struct filter_pred {
14131412
unsigned short *ops;
14141413
struct ftrace_event_field *field;
14151414
int offset;
1416-
int not;
1415+
int not;
14171416
int op;
1418-
unsigned short index;
1419-
unsigned short parent;
1420-
unsigned short left;
1421-
unsigned short right;
14221417
};
14231418

14241419
static inline bool is_string_field(struct ftrace_event_field *field)

0 commit comments

Comments
 (0)