aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2011-08-11 10:25:51 -0400
committerSteven Rostedt <rostedt@goodmis.org>2011-08-19 14:35:56 -0400
commit1b797fe5aaac11e60fce1592119d0517e95aba95 (patch)
tree276dd2cfff0e2ec8a62c2f63662f55e52822aa1f /kernel
parentc00b060f36e1238816ebcf2c8cccd5e9fa068980 (diff)
tracing/filter: Change fold_pred_tree function to use walk_pred_tree
Changing fold_pred_tree function to use unified predicates tree processing. Signed-off-by: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/r/1313072754-4620-8-git-send-email-jolsa@redhat.com Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/trace/trace_events_filter.c65
1 files changed, 20 insertions, 45 deletions
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index ebbb2611982e..d8aa100cb22e 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -1496,6 +1496,24 @@ static int fold_pred(struct filter_pred *preds, struct filter_pred *root)
1496 return 0; 1496 return 0;
1497} 1497}
1498 1498
1499static int fold_pred_tree_cb(enum move_type move, struct filter_pred *pred,
1500 int *err, void *data)
1501{
1502 struct filter_pred *preds = data;
1503
1504 if (move != MOVE_DOWN)
1505 return WALK_PRED_DEFAULT;
1506 if (!(pred->index & FILTER_PRED_FOLD))
1507 return WALK_PRED_DEFAULT;
1508
1509 *err = fold_pred(preds, pred);
1510 if (*err)
1511 return WALK_PRED_ABORT;
1512
1513 /* eveyrhing below is folded, continue with parent */
1514 return WALK_PRED_PARENT;
1515}
1516
1499/* 1517/*
1500 * To optimize the processing of the ops, if we have several "ors" or 1518 * To optimize the processing of the ops, if we have several "ors" or
1501 * "ands" together, we can put them in an array and process them all 1519 * "ands" together, we can put them in an array and process them all
@@ -1504,51 +1522,8 @@ static int fold_pred(struct filter_pred *preds, struct filter_pred *root)
1504static int fold_pred_tree(struct event_filter *filter, 1522static int fold_pred_tree(struct event_filter *filter,
1505 struct filter_pred *root) 1523 struct filter_pred *root)
1506{ 1524{
1507 struct filter_pred *preds; 1525 return walk_pred_tree(filter->preds, root, fold_pred_tree_cb,
1508 struct filter_pred *pred; 1526 filter->preds);
1509 enum move_type move = MOVE_DOWN;
1510 int done = 0;
1511 int err;
1512
1513 preds = filter->preds;
1514 if (!preds)
1515 return -EINVAL;
1516 pred = root;
1517
1518 do {
1519 switch (move) {
1520 case MOVE_DOWN:
1521 if (pred->index & FILTER_PRED_FOLD) {
1522 err = fold_pred(preds, pred);
1523 if (err)
1524 return err;
1525 /* Folded nodes are like leafs */
1526 } else if (pred->left != FILTER_PRED_INVALID) {
1527 pred = &preds[pred->left];
1528 continue;
1529 }
1530
1531 /* A leaf at the root is just a leaf in the tree */
1532 if (pred == root)
1533 break;
1534 pred = get_pred_parent(pred, preds,
1535 pred->parent, &move);
1536 continue;
1537 case MOVE_UP_FROM_LEFT:
1538 pred = &preds[pred->right];
1539 move = MOVE_DOWN;
1540 continue;
1541 case MOVE_UP_FROM_RIGHT:
1542 if (pred == root)
1543 break;
1544 pred = get_pred_parent(pred, preds,
1545 pred->parent, &move);
1546 continue;
1547 }
1548 done = 1;
1549 } while (!done);
1550
1551 return 0;
1552} 1527}
1553 1528
1554static int replace_preds(struct ftrace_event_call *call, 1529static int replace_preds(struct ftrace_event_call *call,