diff options
-rw-r--r-- | kernel/trace/trace.h | 3 | ||||
-rw-r--r-- | kernel/trace/trace_events_filter.c | 51 |
2 files changed, 20 insertions, 34 deletions
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 9021f8c0c0c3..1597bc0749c1 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
@@ -677,8 +677,7 @@ struct event_subsystem { | |||
677 | struct filter_pred; | 677 | struct filter_pred; |
678 | struct regex; | 678 | struct regex; |
679 | 679 | ||
680 | typedef int (*filter_pred_fn_t) (struct filter_pred *pred, void *event, | 680 | typedef int (*filter_pred_fn_t) (struct filter_pred *pred, void *event); |
681 | int val1, int val2); | ||
682 | 681 | ||
683 | typedef int (*regex_match_func)(char *str, struct regex *r, int len); | 682 | typedef int (*regex_match_func)(char *str, struct regex *r, int len); |
684 | 683 | ||
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c index 7275f0310ed8..5d719b340a2b 100644 --- a/kernel/trace/trace_events_filter.c +++ b/kernel/trace/trace_events_filter.c | |||
@@ -124,8 +124,7 @@ struct filter_parse_state { | |||
124 | }; | 124 | }; |
125 | 125 | ||
126 | #define DEFINE_COMPARISON_PRED(type) \ | 126 | #define DEFINE_COMPARISON_PRED(type) \ |
127 | static int filter_pred_##type(struct filter_pred *pred, void *event, \ | 127 | static int filter_pred_##type(struct filter_pred *pred, void *event) \ |
128 | int val1, int val2) \ | ||
129 | { \ | 128 | { \ |
130 | type *addr = (type *)(event + pred->offset); \ | 129 | type *addr = (type *)(event + pred->offset); \ |
131 | type val = (type)pred->val; \ | 130 | type val = (type)pred->val; \ |
@@ -152,8 +151,7 @@ static int filter_pred_##type(struct filter_pred *pred, void *event, \ | |||
152 | } | 151 | } |
153 | 152 | ||
154 | #define DEFINE_EQUALITY_PRED(size) \ | 153 | #define DEFINE_EQUALITY_PRED(size) \ |
155 | static int filter_pred_##size(struct filter_pred *pred, void *event, \ | 154 | static int filter_pred_##size(struct filter_pred *pred, void *event) \ |
156 | int val1, int val2) \ | ||
157 | { \ | 155 | { \ |
158 | u##size *addr = (u##size *)(event + pred->offset); \ | 156 | u##size *addr = (u##size *)(event + pred->offset); \ |
159 | u##size val = (u##size)pred->val; \ | 157 | u##size val = (u##size)pred->val; \ |
@@ -178,23 +176,8 @@ DEFINE_EQUALITY_PRED(32); | |||
178 | DEFINE_EQUALITY_PRED(16); | 176 | DEFINE_EQUALITY_PRED(16); |
179 | DEFINE_EQUALITY_PRED(8); | 177 | DEFINE_EQUALITY_PRED(8); |
180 | 178 | ||
181 | static int filter_pred_and(struct filter_pred *pred __attribute((unused)), | ||
182 | void *event __attribute((unused)), | ||
183 | int val1, int val2) | ||
184 | { | ||
185 | return val1 && val2; | ||
186 | } | ||
187 | |||
188 | static int filter_pred_or(struct filter_pred *pred __attribute((unused)), | ||
189 | void *event __attribute((unused)), | ||
190 | int val1, int val2) | ||
191 | { | ||
192 | return val1 || val2; | ||
193 | } | ||
194 | |||
195 | /* Filter predicate for fixed sized arrays of characters */ | 179 | /* Filter predicate for fixed sized arrays of characters */ |
196 | static int filter_pred_string(struct filter_pred *pred, void *event, | 180 | static int filter_pred_string(struct filter_pred *pred, void *event) |
197 | int val1, int val2) | ||
198 | { | 181 | { |
199 | char *addr = (char *)(event + pred->offset); | 182 | char *addr = (char *)(event + pred->offset); |
200 | int cmp, match; | 183 | int cmp, match; |
@@ -207,8 +190,7 @@ static int filter_pred_string(struct filter_pred *pred, void *event, | |||
207 | } | 190 | } |
208 | 191 | ||
209 | /* Filter predicate for char * pointers */ | 192 | /* Filter predicate for char * pointers */ |
210 | static int filter_pred_pchar(struct filter_pred *pred, void *event, | 193 | static int filter_pred_pchar(struct filter_pred *pred, void *event) |
211 | int val1, int val2) | ||
212 | { | 194 | { |
213 | char **addr = (char **)(event + pred->offset); | 195 | char **addr = (char **)(event + pred->offset); |
214 | int cmp, match; | 196 | int cmp, match; |
@@ -231,8 +213,7 @@ static int filter_pred_pchar(struct filter_pred *pred, void *event, | |||
231 | * and add it to the address of the entry, and at last we have | 213 | * and add it to the address of the entry, and at last we have |
232 | * the address of the string. | 214 | * the address of the string. |
233 | */ | 215 | */ |
234 | static int filter_pred_strloc(struct filter_pred *pred, void *event, | 216 | static int filter_pred_strloc(struct filter_pred *pred, void *event) |
235 | int val1, int val2) | ||
236 | { | 217 | { |
237 | u32 str_item = *(u32 *)(event + pred->offset); | 218 | u32 str_item = *(u32 *)(event + pred->offset); |
238 | int str_loc = str_item & 0xffff; | 219 | int str_loc = str_item & 0xffff; |
@@ -247,8 +228,7 @@ static int filter_pred_strloc(struct filter_pred *pred, void *event, | |||
247 | return match; | 228 | return match; |
248 | } | 229 | } |
249 | 230 | ||
250 | static int filter_pred_none(struct filter_pred *pred, void *event, | 231 | static int filter_pred_none(struct filter_pred *pred, void *event) |
251 | int val1, int val2) | ||
252 | { | 232 | { |
253 | return 0; | 233 | return 0; |
254 | } | 234 | } |
@@ -380,7 +360,7 @@ static void filter_build_regex(struct filter_pred *pred) | |||
380 | /* return 1 if event matches, 0 otherwise (discard) */ | 360 | /* return 1 if event matches, 0 otherwise (discard) */ |
381 | int filter_match_preds(struct event_filter *filter, void *rec) | 361 | int filter_match_preds(struct event_filter *filter, void *rec) |
382 | { | 362 | { |
383 | int match, top = 0, val1 = 0, val2 = 0; | 363 | int match = -1, top = 0, val1 = 0, val2 = 0; |
384 | int stack[MAX_FILTER_PRED]; | 364 | int stack[MAX_FILTER_PRED]; |
385 | struct filter_pred *pred; | 365 | struct filter_pred *pred; |
386 | int n_preds = ACCESS_ONCE(filter->n_preds); | 366 | int n_preds = ACCESS_ONCE(filter->n_preds); |
@@ -393,7 +373,7 @@ int filter_match_preds(struct event_filter *filter, void *rec) | |||
393 | for (i = 0; i < n_preds; i++) { | 373 | for (i = 0; i < n_preds; i++) { |
394 | pred = filter->preds[i]; | 374 | pred = filter->preds[i]; |
395 | if (!pred->pop_n) { | 375 | if (!pred->pop_n) { |
396 | match = pred->fn(pred, rec, val1, val2); | 376 | match = pred->fn(pred, rec); |
397 | stack[top++] = match; | 377 | stack[top++] = match; |
398 | continue; | 378 | continue; |
399 | } | 379 | } |
@@ -403,7 +383,16 @@ int filter_match_preds(struct event_filter *filter, void *rec) | |||
403 | } | 383 | } |
404 | val1 = stack[--top]; | 384 | val1 = stack[--top]; |
405 | val2 = stack[--top]; | 385 | val2 = stack[--top]; |
406 | match = pred->fn(pred, rec, val1, val2); | 386 | switch (pred->op) { |
387 | case OP_AND: | ||
388 | match = val1 && val2; | ||
389 | break; | ||
390 | case OP_OR: | ||
391 | match = val1 || val2; | ||
392 | break; | ||
393 | default: | ||
394 | WARN_ONCE(1, "filter op is not AND or OR"); | ||
395 | } | ||
407 | stack[top++] = match; | 396 | stack[top++] = match; |
408 | } | 397 | } |
409 | 398 | ||
@@ -775,15 +764,13 @@ static int filter_add_pred(struct filter_parse_state *ps, | |||
775 | unsigned long long val; | 764 | unsigned long long val; |
776 | int ret; | 765 | int ret; |
777 | 766 | ||
778 | pred->fn = filter_pred_none; | 767 | fn = pred->fn = filter_pred_none; |
779 | 768 | ||
780 | if (pred->op == OP_AND) { | 769 | if (pred->op == OP_AND) { |
781 | pred->pop_n = 2; | 770 | pred->pop_n = 2; |
782 | fn = filter_pred_and; | ||
783 | goto add_pred_fn; | 771 | goto add_pred_fn; |
784 | } else if (pred->op == OP_OR) { | 772 | } else if (pred->op == OP_OR) { |
785 | pred->pop_n = 2; | 773 | pred->pop_n = 2; |
786 | fn = filter_pred_or; | ||
787 | goto add_pred_fn; | 774 | goto add_pred_fn; |
788 | } | 775 | } |
789 | 776 | ||