Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 269071
b: refs/heads/master
c: 96bc293
h: refs/heads/master
i:
  269069: cd4d79d
  269067: fa741e6
  269063: 00eb1f5
  269055: 1a7b06a
v: v3
  • Loading branch information
Jiri Olsa authored and Steven Rostedt committed Aug 19, 2011
1 parent fc7d890 commit 4d93091
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 36 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1b797fe5aaac11e60fce1592119d0517e95aba95
refs/heads/master: 96bc293a97e7f1651977976be7dd42031f6d8ea3
68 changes: 33 additions & 35 deletions trunk/kernel/trace/trace_events_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1439,13 +1439,40 @@ static int count_leafs(struct filter_pred *preds, struct filter_pred *root)
return count;
}

struct fold_pred_data {
struct filter_pred *root;
int count;
int children;
};

static int fold_pred_cb(enum move_type move, struct filter_pred *pred,
int *err, void *data)
{
struct fold_pred_data *d = data;
struct filter_pred *root = d->root;

if (move != MOVE_DOWN)
return WALK_PRED_DEFAULT;
if (pred->left != FILTER_PRED_INVALID)
return WALK_PRED_DEFAULT;

if (WARN_ON(d->count == d->children)) {
*err = -EINVAL;
return WALK_PRED_ABORT;
}

pred->index &= ~FILTER_PRED_FOLD;
root->ops[d->count++] = pred->index;
return WALK_PRED_DEFAULT;
}

static int fold_pred(struct filter_pred *preds, struct filter_pred *root)
{
struct filter_pred *pred;
enum move_type move = MOVE_DOWN;
int count = 0;
struct fold_pred_data data = {
.root = root,
.count = 0,
};
int children;
int done = 0;

/* No need to keep the fold flag */
root->index &= ~FILTER_PRED_FOLD;
Expand All @@ -1463,37 +1490,8 @@ static int fold_pred(struct filter_pred *preds, struct filter_pred *root)
return -ENOMEM;

root->val = children;

pred = root;
do {
switch (move) {
case MOVE_DOWN:
if (pred->left != FILTER_PRED_INVALID) {
pred = &preds[pred->left];
continue;
}
if (WARN_ON(count == children))
return -EINVAL;
pred->index &= ~FILTER_PRED_FOLD;
root->ops[count++] = pred->index;
pred = get_pred_parent(pred, preds,
pred->parent, &move);
continue;
case MOVE_UP_FROM_LEFT:
pred = &preds[pred->right];
move = MOVE_DOWN;
continue;
case MOVE_UP_FROM_RIGHT:
if (pred == root)
break;
pred = get_pred_parent(pred, preds,
pred->parent, &move);
continue;
}
done = 1;
} while (!done);

return 0;
data.children = children;
return walk_pred_tree(preds, root, fold_pred_cb, &data);
}

static int fold_pred_tree_cb(enum move_type move, struct filter_pred *pred,
Expand Down

0 comments on commit 4d93091

Please sign in to comment.