diff options
| author | Jiri Olsa <jolsa@redhat.com> | 2011-08-11 10:25:47 -0400 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2011-08-19 14:35:52 -0400 |
| commit | 61aaef55300088e12d7f853adeea65d1aa1562db (patch) | |
| tree | 2f902bf96330b9727ec3d82b9ff92b83cb79636c /kernel/trace | |
| parent | 9d96cd1743547f07a8a6c51a3f7741cfca0a0bee (diff) | |
tracing/filter: Remove field_name from filter_pred struct
The field_name was used just for finding event's fields. This way we
don't need to care about field_name allocation/free.
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/1313072754-4620-4-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.h | 11 | ||||
| -rw-r--r-- | kernel/trace/trace_events_filter.c | 53 |
2 files changed, 13 insertions, 51 deletions
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 616846bcfee5..2eb3cf6d37bc 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
| @@ -761,16 +761,7 @@ struct filter_pred { | |||
| 761 | filter_pred_fn_t fn; | 761 | filter_pred_fn_t fn; |
| 762 | u64 val; | 762 | u64 val; |
| 763 | struct regex regex; | 763 | struct regex regex; |
| 764 | /* | 764 | unsigned short *ops; |
| 765 | * Leaf nodes use field_name, ops is used by AND and OR | ||
| 766 | * nodes. The field_name is always freed when freeing a pred. | ||
| 767 | * We can overload field_name for ops and have it freed | ||
| 768 | * as well. | ||
| 769 | */ | ||
| 770 | union { | ||
| 771 | char *field_name; | ||
| 772 | unsigned short *ops; | ||
| 773 | }; | ||
| 774 | int offset; | 765 | int offset; |
| 775 | int not; | 766 | int not; |
| 776 | int op; | 767 | int op; |
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c index 61c8dec3b2b7..97b93f31884b 100644 --- a/kernel/trace/trace_events_filter.c +++ b/kernel/trace/trace_events_filter.c | |||
| @@ -628,18 +628,6 @@ find_event_field(struct ftrace_event_call *call, char *name) | |||
| 628 | return __find_event_field(head, name); | 628 | return __find_event_field(head, name); |
| 629 | } | 629 | } |
| 630 | 630 | ||
| 631 | static void filter_free_pred(struct filter_pred *pred) | ||
| 632 | { | ||
| 633 | kfree(pred->field_name); | ||
| 634 | } | ||
| 635 | |||
| 636 | static void filter_clear_pred(struct filter_pred *pred) | ||
| 637 | { | ||
| 638 | kfree(pred->field_name); | ||
| 639 | pred->field_name = NULL; | ||
| 640 | pred->regex.len = 0; | ||
| 641 | } | ||
| 642 | |||
| 643 | static int __alloc_pred_stack(struct pred_stack *stack, int n_preds) | 631 | static int __alloc_pred_stack(struct pred_stack *stack, int n_preds) |
| 644 | { | 632 | { |
| 645 | stack->preds = kzalloc(sizeof(*stack->preds)*(n_preds + 1), GFP_KERNEL); | 633 | stack->preds = kzalloc(sizeof(*stack->preds)*(n_preds + 1), GFP_KERNEL); |
| @@ -692,11 +680,6 @@ static int filter_set_pred(struct event_filter *filter, | |||
| 692 | struct filter_pred *right; | 680 | struct filter_pred *right; |
| 693 | 681 | ||
| 694 | *dest = *src; | 682 | *dest = *src; |
| 695 | if (src->field_name) { | ||
| 696 | dest->field_name = kstrdup(src->field_name, GFP_KERNEL); | ||
| 697 | if (!dest->field_name) | ||
| 698 | return -ENOMEM; | ||
| 699 | } | ||
| 700 | dest->index = idx; | 683 | dest->index = idx; |
| 701 | 684 | ||
| 702 | if (dest->op == OP_OR || dest->op == OP_AND) { | 685 | if (dest->op == OP_OR || dest->op == OP_AND) { |
| @@ -737,11 +720,7 @@ static int filter_set_pred(struct event_filter *filter, | |||
| 737 | 720 | ||
| 738 | static void __free_preds(struct event_filter *filter) | 721 | static void __free_preds(struct event_filter *filter) |
| 739 | { | 722 | { |
| 740 | int i; | ||
| 741 | |||
| 742 | if (filter->preds) { | 723 | if (filter->preds) { |
| 743 | for (i = 0; i < filter->a_preds; i++) | ||
| 744 | kfree(filter->preds[i].field_name); | ||
| 745 | kfree(filter->preds); | 724 | kfree(filter->preds); |
| 746 | filter->preds = NULL; | 725 | filter->preds = NULL; |
| 747 | } | 726 | } |
| @@ -839,16 +818,14 @@ static int filter_add_pred(struct filter_parse_state *ps, | |||
| 839 | struct filter_pred *pred, | 818 | struct filter_pred *pred, |
| 840 | struct pred_stack *stack) | 819 | struct pred_stack *stack) |
| 841 | { | 820 | { |
| 842 | int idx, err; | 821 | int err; |
| 843 | 822 | ||
| 844 | if (WARN_ON(filter->n_preds == filter->a_preds)) { | 823 | if (WARN_ON(filter->n_preds == filter->a_preds)) { |
| 845 | parse_error(ps, FILT_ERR_TOO_MANY_PREDS, 0); | 824 | parse_error(ps, FILT_ERR_TOO_MANY_PREDS, 0); |
| 846 | return -ENOSPC; | 825 | return -ENOSPC; |
| 847 | } | 826 | } |
| 848 | 827 | ||
| 849 | idx = filter->n_preds; | 828 | err = filter_set_pred(filter, filter->n_preds, stack, pred); |
| 850 | filter_clear_pred(&filter->preds[idx]); | ||
| 851 | err = filter_set_pred(filter, idx, stack, pred); | ||
| 852 | if (err) | 829 | if (err) |
| 853 | return err; | 830 | return err; |
| 854 | 831 | ||
| @@ -930,21 +907,14 @@ static filter_pred_fn_t select_comparison_fn(int op, int field_size, | |||
| 930 | } | 907 | } |
| 931 | 908 | ||
| 932 | static int init_pred(struct filter_parse_state *ps, | 909 | static int init_pred(struct filter_parse_state *ps, |
| 933 | struct ftrace_event_call *call, | 910 | struct ftrace_event_field *field, |
| 934 | struct filter_pred *pred) | 911 | struct filter_pred *pred) |
| 935 | 912 | ||
| 936 | { | 913 | { |
| 937 | struct ftrace_event_field *field; | ||
| 938 | filter_pred_fn_t fn = filter_pred_none; | 914 | filter_pred_fn_t fn = filter_pred_none; |
| 939 | unsigned long long val; | 915 | unsigned long long val; |
| 940 | int ret; | 916 | int ret; |
| 941 | 917 | ||
| 942 | field = find_event_field(call, pred->field_name); | ||
| 943 | if (!field) { | ||
| 944 | parse_error(ps, FILT_ERR_FIELD_NOT_FOUND, 0); | ||
| 945 | return -EINVAL; | ||
| 946 | } | ||
| 947 | |||
| 948 | pred->offset = field->offset; | 918 | pred->offset = field->offset; |
| 949 | 919 | ||
| 950 | if (!is_legal_op(field, pred->op)) { | 920 | if (!is_legal_op(field, pred->op)) { |
| @@ -1287,6 +1257,7 @@ static struct filter_pred *create_pred(struct filter_parse_state *ps, | |||
| 1287 | struct ftrace_event_call *call, | 1257 | struct ftrace_event_call *call, |
| 1288 | int op, char *operand1, char *operand2) | 1258 | int op, char *operand1, char *operand2) |
| 1289 | { | 1259 | { |
| 1260 | struct ftrace_event_field *field; | ||
| 1290 | static struct filter_pred pred; | 1261 | static struct filter_pred pred; |
| 1291 | 1262 | ||
| 1292 | memset(&pred, 0, sizeof(pred)); | 1263 | memset(&pred, 0, sizeof(pred)); |
| @@ -1300,14 +1271,16 @@ static struct filter_pred *create_pred(struct filter_parse_state *ps, | |||
| 1300 | return NULL; | 1271 | return NULL; |
| 1301 | } | 1272 | } |
| 1302 | 1273 | ||
| 1303 | pred.field_name = kstrdup(operand1, GFP_KERNEL); | 1274 | field = find_event_field(call, operand1); |
| 1304 | if (!pred.field_name) | 1275 | if (!field) { |
| 1276 | parse_error(ps, FILT_ERR_FIELD_NOT_FOUND, 0); | ||
| 1305 | return NULL; | 1277 | return NULL; |
| 1278 | } | ||
| 1306 | 1279 | ||
| 1307 | strcpy(pred.regex.pattern, operand2); | 1280 | strcpy(pred.regex.pattern, operand2); |
| 1308 | pred.regex.len = strlen(pred.regex.pattern); | 1281 | pred.regex.len = strlen(pred.regex.pattern); |
| 1309 | 1282 | ||
| 1310 | return init_pred(ps, call, &pred) ? NULL : &pred; | 1283 | return init_pred(ps, field, &pred) ? NULL : &pred; |
| 1311 | } | 1284 | } |
| 1312 | 1285 | ||
| 1313 | static int check_preds(struct filter_parse_state *ps) | 1286 | static int check_preds(struct filter_parse_state *ps) |
| @@ -1618,18 +1591,16 @@ static int replace_preds(struct ftrace_event_call *call, | |||
| 1618 | 1591 | ||
| 1619 | pred = create_pred(ps, call, elt->op, operand1, operand2); | 1592 | pred = create_pred(ps, call, elt->op, operand1, operand2); |
| 1620 | if (!pred) { | 1593 | if (!pred) { |
| 1621 | err = -ENOMEM; | 1594 | err = -EINVAL; |
| 1622 | goto fail; | 1595 | goto fail; |
| 1623 | } | 1596 | } |
| 1597 | |||
| 1624 | if (!dry_run) { | 1598 | if (!dry_run) { |
| 1625 | err = filter_add_pred(ps, filter, pred, &stack); | 1599 | err = filter_add_pred(ps, filter, pred, &stack); |
| 1626 | if (err) { | 1600 | if (err) |
| 1627 | filter_free_pred(pred); | ||
| 1628 | goto fail; | 1601 | goto fail; |
| 1629 | } | ||
| 1630 | } | 1602 | } |
| 1631 | 1603 | ||
| 1632 | filter_free_pred(pred); | ||
| 1633 | operand1 = operand2 = NULL; | 1604 | operand1 = operand2 = NULL; |
| 1634 | } | 1605 | } |
| 1635 | 1606 | ||
