diff options
author | Steven Rostedt <srostedt@redhat.com> | 2011-01-27 23:16:51 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2011-02-07 20:56:19 -0500 |
commit | 43cd414552d8137157e926e46361678ea867e476 (patch) | |
tree | cbb50e071a8149e2da7be995166f487bbcb5172a /kernel/trace/trace.h | |
parent | ec126cac23945de12eb2d103374e1f7ee97c5595 (diff) |
tracing/filter: Optimize filter by folding the tree
There are many cases that a filter will contain multiple ORs or
ANDs together near the leafs. Walking up and down the tree to get
to the next compare can be a waste.
If there are several ORs or ANDs together, fold them into a single
pred and allocate an array of the conditions that they check.
This will speed up the filter by linearly walking an array
and can still break out if a short circuit condition is met.
Cc: Tom Zanussi <tzanussi@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace/trace.h')
-rw-r--r-- | kernel/trace/trace.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index bba34a72c780..d754330934bb 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
@@ -678,6 +678,7 @@ struct event_subsystem { | |||
678 | 678 | ||
679 | #define FILTER_PRED_INVALID ((unsigned short)-1) | 679 | #define FILTER_PRED_INVALID ((unsigned short)-1) |
680 | #define FILTER_PRED_IS_RIGHT (1 << 15) | 680 | #define FILTER_PRED_IS_RIGHT (1 << 15) |
681 | #define FILTER_PRED_FOLD (1 << 15) | ||
681 | 682 | ||
682 | struct filter_pred; | 683 | struct filter_pred; |
683 | struct regex; | 684 | struct regex; |
@@ -704,7 +705,16 @@ struct filter_pred { | |||
704 | filter_pred_fn_t fn; | 705 | filter_pred_fn_t fn; |
705 | u64 val; | 706 | u64 val; |
706 | struct regex regex; | 707 | struct regex regex; |
707 | char *field_name; | 708 | /* |
709 | * Leaf nodes use field_name, ops is used by AND and OR | ||
710 | * nodes. The field_name is always freed when freeing a pred. | ||
711 | * We can overload field_name for ops and have it freed | ||
712 | * as well. | ||
713 | */ | ||
714 | union { | ||
715 | char *field_name; | ||
716 | unsigned short *ops; | ||
717 | }; | ||
708 | int offset; | 718 | int offset; |
709 | int not; | 719 | int not; |
710 | int op; | 720 | int op; |