diff options
author | Jiri Olsa <jolsa@redhat.com> | 2011-08-11 10:25:52 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2011-08-19 14:35:57 -0400 |
commit | 96bc293a97e7f1651977976be7dd42031f6d8ea3 (patch) | |
tree | e243a1c53c24835574085426ee3b9021a1c15360 | |
parent | 1b797fe5aaac11e60fce1592119d0517e95aba95 (diff) |
tracing/filter: Change fold_pred 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-9-git-send-email-jolsa@redhat.com
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | kernel/trace/trace_events_filter.c | 68 |
1 files changed, 33 insertions, 35 deletions
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c index d8aa100cb22e..f44e68b89f15 100644 --- a/kernel/trace/trace_events_filter.c +++ b/kernel/trace/trace_events_filter.c | |||
@@ -1439,13 +1439,40 @@ static int count_leafs(struct filter_pred *preds, struct filter_pred *root) | |||
1439 | return count; | 1439 | return count; |
1440 | } | 1440 | } |
1441 | 1441 | ||
1442 | struct fold_pred_data { | ||
1443 | struct filter_pred *root; | ||
1444 | int count; | ||
1445 | int children; | ||
1446 | }; | ||
1447 | |||
1448 | static int fold_pred_cb(enum move_type move, struct filter_pred *pred, | ||
1449 | int *err, void *data) | ||
1450 | { | ||
1451 | struct fold_pred_data *d = data; | ||
1452 | struct filter_pred *root = d->root; | ||
1453 | |||
1454 | if (move != MOVE_DOWN) | ||
1455 | return WALK_PRED_DEFAULT; | ||
1456 | if (pred->left != FILTER_PRED_INVALID) | ||
1457 | return WALK_PRED_DEFAULT; | ||
1458 | |||
1459 | if (WARN_ON(d->count == d->children)) { | ||
1460 | *err = -EINVAL; | ||
1461 | return WALK_PRED_ABORT; | ||
1462 | } | ||
1463 | |||
1464 | pred->index &= ~FILTER_PRED_FOLD; | ||
1465 | root->ops[d->count++] = pred->index; | ||
1466 | return WALK_PRED_DEFAULT; | ||
1467 | } | ||
1468 | |||
1442 | static int fold_pred(struct filter_pred *preds, struct filter_pred *root) | 1469 | static int fold_pred(struct filter_pred *preds, struct filter_pred *root) |
1443 | { | 1470 | { |
1444 | struct filter_pred *pred; | 1471 | struct fold_pred_data data = { |
1445 | enum move_type move = MOVE_DOWN; | 1472 | .root = root, |
1446 | int count = 0; | 1473 | .count = 0, |
1474 | }; | ||
1447 | int children; | 1475 | int children; |
1448 | int done = 0; | ||
1449 | 1476 | ||
1450 | /* No need to keep the fold flag */ | 1477 | /* No need to keep the fold flag */ |
1451 | root->index &= ~FILTER_PRED_FOLD; | 1478 | root->index &= ~FILTER_PRED_FOLD; |
@@ -1463,37 +1490,8 @@ static int fold_pred(struct filter_pred *preds, struct filter_pred *root) | |||
1463 | return -ENOMEM; | 1490 | return -ENOMEM; |
1464 | 1491 | ||
1465 | root->val = children; | 1492 | root->val = children; |
1466 | 1493 | data.children = children; | |
1467 | pred = root; | 1494 | return walk_pred_tree(preds, root, fold_pred_cb, &data); |
1468 | do { | ||
1469 | switch (move) { | ||
1470 | case MOVE_DOWN: | ||
1471 | if (pred->left != FILTER_PRED_INVALID) { | ||
1472 | pred = &preds[pred->left]; | ||
1473 | continue; | ||
1474 | } | ||
1475 | if (WARN_ON(count == children)) | ||
1476 | return -EINVAL; | ||
1477 | pred->index &= ~FILTER_PRED_FOLD; | ||
1478 | root->ops[count++] = pred->index; | ||
1479 | pred = get_pred_parent(pred, preds, | ||
1480 | pred->parent, &move); | ||
1481 | continue; | ||
1482 | case MOVE_UP_FROM_LEFT: | ||
1483 | pred = &preds[pred->right]; | ||
1484 | move = MOVE_DOWN; | ||
1485 | continue; | ||
1486 | case MOVE_UP_FROM_RIGHT: | ||
1487 | if (pred == root) | ||
1488 | break; | ||
1489 | pred = get_pred_parent(pred, preds, | ||
1490 | pred->parent, &move); | ||
1491 | continue; | ||
1492 | } | ||
1493 | done = 1; | ||
1494 | } while (!done); | ||
1495 | |||
1496 | return 0; | ||
1497 | } | 1495 | } |
1498 | 1496 | ||
1499 | static int fold_pred_tree_cb(enum move_type move, struct filter_pred *pred, | 1497 | static int fold_pred_tree_cb(enum move_type move, struct filter_pred *pred, |