aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2011-08-11 10:25:46 -0400
committerSteven Rostedt <rostedt@goodmis.org>2011-08-19 14:35:51 -0400
commit9d96cd1743547f07a8a6c51a3f7741cfca0a0bee (patch)
treeb013bf238a63661eccb7134b0e9631ff09464a47 /kernel/trace
parent81570d9caaad46a056580c9af078c5c55e6c764f (diff)
tracing/filter: Separate predicate init and filter addition
Making the code cleaner by having one function to fully prepare the predicate (create_pred), and another to add the predicate to the filter (filter_add_pred). As a benefit, this way the dry_run flag stays only inside the replace_preds function and is not passed deeper. Signed-off-by: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/r/1313072754-4620-3-git-send-email-jolsa@redhat.com Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace')
-rw-r--r--kernel/trace/trace_events_filter.c56
1 files changed, 23 insertions, 33 deletions
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index cb295a117ee7..61c8dec3b2b7 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -685,8 +685,7 @@ __pop_pred_stack(struct pred_stack *stack)
685static int filter_set_pred(struct event_filter *filter, 685static int filter_set_pred(struct event_filter *filter,
686 int idx, 686 int idx,
687 struct pred_stack *stack, 687 struct pred_stack *stack,
688 struct filter_pred *src, 688 struct filter_pred *src)
689 filter_pred_fn_t fn)
690{ 689{
691 struct filter_pred *dest = &filter->preds[idx]; 690 struct filter_pred *dest = &filter->preds[idx];
692 struct filter_pred *left; 691 struct filter_pred *left;
@@ -698,7 +697,6 @@ static int filter_set_pred(struct event_filter *filter,
698 if (!dest->field_name) 697 if (!dest->field_name)
699 return -ENOMEM; 698 return -ENOMEM;
700 } 699 }
701 dest->fn = fn;
702 dest->index = idx; 700 dest->index = idx;
703 701
704 if (dest->op == OP_OR || dest->op == OP_AND) { 702 if (dest->op == OP_OR || dest->op == OP_AND) {
@@ -836,12 +834,10 @@ static void filter_free_subsystem_filters(struct event_subsystem *system)
836 } 834 }
837} 835}
838 836
839static int filter_add_pred_fn(struct filter_parse_state *ps, 837static int filter_add_pred(struct filter_parse_state *ps,
840 struct ftrace_event_call *call, 838 struct event_filter *filter,
841 struct event_filter *filter, 839 struct filter_pred *pred,
842 struct filter_pred *pred, 840 struct pred_stack *stack)
843 struct pred_stack *stack,
844 filter_pred_fn_t fn)
845{ 841{
846 int idx, err; 842 int idx, err;
847 843
@@ -852,7 +848,7 @@ static int filter_add_pred_fn(struct filter_parse_state *ps,
852 848
853 idx = filter->n_preds; 849 idx = filter->n_preds;
854 filter_clear_pred(&filter->preds[idx]); 850 filter_clear_pred(&filter->preds[idx]);
855 err = filter_set_pred(filter, idx, stack, pred, fn); 851 err = filter_set_pred(filter, idx, stack, pred);
856 if (err) 852 if (err)
857 return err; 853 return err;
858 854
@@ -933,25 +929,16 @@ static filter_pred_fn_t select_comparison_fn(int op, int field_size,
933 return fn; 929 return fn;
934} 930}
935 931
936static int filter_add_pred(struct filter_parse_state *ps, 932static int init_pred(struct filter_parse_state *ps,
937 struct ftrace_event_call *call, 933 struct ftrace_event_call *call,
938 struct event_filter *filter, 934 struct filter_pred *pred)
939 struct filter_pred *pred, 935
940 struct pred_stack *stack,
941 bool dry_run)
942{ 936{
943 struct ftrace_event_field *field; 937 struct ftrace_event_field *field;
944 filter_pred_fn_t fn; 938 filter_pred_fn_t fn = filter_pred_none;
945 unsigned long long val; 939 unsigned long long val;
946 int ret; 940 int ret;
947 941
948 fn = pred->fn = filter_pred_none;
949
950 if (pred->op == OP_AND)
951 goto add_pred_fn;
952 else if (pred->op == OP_OR)
953 goto add_pred_fn;
954
955 field = find_event_field(call, pred->field_name); 942 field = find_event_field(call, pred->field_name);
956 if (!field) { 943 if (!field) {
957 parse_error(ps, FILT_ERR_FIELD_NOT_FOUND, 0); 944 parse_error(ps, FILT_ERR_FIELD_NOT_FOUND, 0);
@@ -997,9 +984,7 @@ static int filter_add_pred(struct filter_parse_state *ps,
997 if (pred->op == OP_NE) 984 if (pred->op == OP_NE)
998 pred->not = 1; 985 pred->not = 1;
999 986
1000add_pred_fn: 987 pred->fn = fn;
1001 if (!dry_run)
1002 return filter_add_pred_fn(ps, call, filter, pred, stack, fn);
1003 return 0; 988 return 0;
1004} 989}
1005 990
@@ -1299,6 +1284,7 @@ parse_operand:
1299} 1284}
1300 1285
1301static struct filter_pred *create_pred(struct filter_parse_state *ps, 1286static struct filter_pred *create_pred(struct filter_parse_state *ps,
1287 struct ftrace_event_call *call,
1302 int op, char *operand1, char *operand2) 1288 int op, char *operand1, char *operand2)
1303{ 1289{
1304 static struct filter_pred pred; 1290 static struct filter_pred pred;
@@ -1321,7 +1307,7 @@ static struct filter_pred *create_pred(struct filter_parse_state *ps,
1321 strcpy(pred.regex.pattern, operand2); 1307 strcpy(pred.regex.pattern, operand2);
1322 pred.regex.len = strlen(pred.regex.pattern); 1308 pred.regex.len = strlen(pred.regex.pattern);
1323 1309
1324 return &pred; 1310 return init_pred(ps, call, &pred) ? NULL : &pred;
1325} 1311}
1326 1312
1327static int check_preds(struct filter_parse_state *ps) 1313static int check_preds(struct filter_parse_state *ps)
@@ -1630,16 +1616,20 @@ static int replace_preds(struct ftrace_event_call *call,
1630 goto fail; 1616 goto fail;
1631 } 1617 }
1632 1618
1633 pred = create_pred(ps, elt->op, operand1, operand2); 1619 pred = create_pred(ps, call, elt->op, operand1, operand2);
1634 if (!pred) { 1620 if (!pred) {
1635 err = -ENOMEM; 1621 err = -ENOMEM;
1636 goto fail; 1622 goto fail;
1637 } 1623 }
1638 err = filter_add_pred(ps, call, filter, pred, &stack, dry_run); 1624 if (!dry_run) {
1639 filter_free_pred(pred); 1625 err = filter_add_pred(ps, filter, pred, &stack);
1640 if (err) 1626 if (err) {
1641 goto fail; 1627 filter_free_pred(pred);
1628 goto fail;
1629 }
1630 }
1642 1631
1632 filter_free_pred(pred);
1643 operand1 = operand2 = NULL; 1633 operand1 = operand2 = NULL;
1644 } 1634 }
1645 1635