tracing: Allow NOT to filter AND and OR clauses
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>
Wed, 3 Dec 2014 00:08:30 +0000 (19:08 -0500)
committerSteven Rostedt <rostedt@goodmis.org>
Wed, 3 Dec 2014 15:00:27 +0000 (10:00 -0500)
Add support to allow not "!" for and (&&) and (||). That is:

 !(field1 == X && field2 == Y)

Where the value of the full clause will be notted.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
kernel/trace/trace_events_filter.c

index e6a33db8385622e238b016dc51d6d8442f7665cc..ced69da0ff55ba08a7358cae7ceaae31546f9332 100644 (file)
@@ -489,9 +489,10 @@ static int process_ops(struct filter_pred *preds,
                if (!WARN_ON_ONCE(!pred->fn))
                        match = pred->fn(pred, rec);
                if (!!match == type)
-                       return match;
+                       break;
        }
-       return match;
+       /* If not of not match is equal to not of not, then it is a match */
+       return !!match == !op->not;
 }
 
 struct filter_match_preds_data {
@@ -740,10 +741,10 @@ static int filter_set_pred(struct event_filter *filter,
                 * then this op can be folded.
                 */
                if (left->index & FILTER_PRED_FOLD &&
-                   (left->op == dest->op ||
+                   ((left->op == dest->op && !left->not) ||
                     left->left == FILTER_PRED_INVALID) &&
                    right->index & FILTER_PRED_FOLD &&
-                   (right->op == dest->op ||
+                   ((right->op == dest->op && !right->not) ||
                     right->left == FILTER_PRED_INVALID))
                        dest->index |= FILTER_PRED_FOLD;