All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
	Theodore Tso <tytso@mit.edu>,
	Alexei Starovoitov <ast@plumgrid.com>
Subject: [PATCH 2/3] tracing: Allow NOT to filter AND and OR clauses
Date: Tue, 02 Dec 2014 22:13:36 -0500	[thread overview]
Message-ID: <20141203032106.019621650@goodmis.org> (raw)
In-Reply-To: 20141203031334.174087814@goodmis.org

[-- Attachment #1: 0002-tracing-Allow-NOT-to-filter-AND-and-OR-clauses.patch --]
[-- Type: text/plain, Size: 1422 bytes --]

From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>

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 | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index e6a33db83856..ced69da0ff55 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -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;
 
-- 
2.1.3



  parent reply	other threads:[~2014-12-03  3:21 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-03  3:13 [PATCH 0/3] tracing: Add event filter logic for !(...) Steven Rostedt
2014-12-03  3:13 ` [PATCH 1/3] tracing: Add NOT to filtering logic Steven Rostedt
2014-12-03  3:13 ` Steven Rostedt [this message]
2014-12-03  3:13 ` [PATCH 3/3] ftracetests: Add test to test event filter logic Steven Rostedt
2014-12-03  6:22   ` Alexei Starovoitov
2014-12-03  8:40     ` Steven Rostedt
2014-12-03 17:53       ` Alexei Starovoitov
2014-12-03 18:01         ` Steven Rostedt
2014-12-03  9:26   ` Masami Hiramatsu
2014-12-03  9:34     ` Steven Rostedt
2014-12-03 16:20       ` Steven Rostedt
2014-12-04  8:12         ` Masami Hiramatsu
2014-12-03 23:14       ` Masami Hiramatsu
2014-12-03 23:29         ` Steven Rostedt
2014-12-04  3:18         ` [PATCH v2] " Steven Rostedt
2014-12-04 10:06           ` Masami Hiramatsu
2014-12-04 12:04             ` Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141203032106.019621650@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=ast@plumgrid.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mingo@kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.