From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Arend van Spriel <arend@broadcom.com>
Subject: [for-next][PATCH 08/12] tracing: Add binary & filter for events
Date: Wed, 19 Jun 2013 23:35:24 -0400 [thread overview]
Message-ID: <20130620033639.723900482@goodmis.org> (raw)
In-Reply-To: 20130620033516.003166252@goodmis.org
[-- Attachment #1: 0008-tracing-Add-binary-filter-for-events.patch --]
[-- Type: text/plain, Size: 2708 bytes --]
From: Steven Rostedt <rostedt@goodmis.org>
There are some cases when filtering on a set flag of a field of a tracepoint
is useful. But currently the only filtering commands for numbered fields
is ==, !=, <, <=, >, >=. This does not help when you just want to trace if
a specific flag is set. For example:
> # sudo trace-cmd record -e brcmfmac:brcmf_dbg -f 'level & 0x40000'
> disable all
> enable brcmfmac:brcmf_dbg
> path = /sys/kernel/debug/tracing/events/brcmfmac/brcmf_dbg/enable
> (level & 0x40000)
> ^
> parse_error: Invalid operator
>
When trying to trace brcmf_dbg when level has its 1 << 18 bit set, the
filter fails to perform.
By allowing a binary '&' operation, this gives the user the ability to
test a bit.
Note, a binary '|' is not added, as it doesn't make sense as fields must
be compared to constants (for now), and ORing a constant will always return
true.
Link: http://lkml.kernel.org/r/1371057385.9844.261.camel@gandalf.local.home
Suggested-by: Arend van Spriel <arend@broadcom.com>
Tested-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
Documentation/trace/events.txt | 2 +-
kernel/trace/trace_events_filter.c | 6 ++++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/Documentation/trace/events.txt b/Documentation/trace/events.txt
index bb24c2a..4191124 100644
--- a/Documentation/trace/events.txt
+++ b/Documentation/trace/events.txt
@@ -183,7 +183,7 @@ The relational-operators depend on the type of the field being tested:
The operators available for numeric fields are:
-==, !=, <, <=, >, >=
+==, !=, <, <=, >, >=, &
And for string fields they are:
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index e1b653f..0d883dc 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -44,6 +44,7 @@ enum filter_op_ids
OP_LE,
OP_GT,
OP_GE,
+ OP_BAND,
OP_NONE,
OP_OPEN_PAREN,
};
@@ -54,6 +55,7 @@ struct filter_op {
int precedence;
};
+/* Order must be the same as enum filter_op_ids above */
static struct filter_op filter_ops[] = {
{ OP_OR, "||", 1 },
{ OP_AND, "&&", 2 },
@@ -64,6 +66,7 @@ static struct filter_op filter_ops[] = {
{ OP_LE, "<=", 5 },
{ OP_GT, ">", 5 },
{ OP_GE, ">=", 5 },
+ { OP_BAND, "&", 6 },
{ OP_NONE, "OP_NONE", 0 },
{ OP_OPEN_PAREN, "(", 0 },
};
@@ -156,6 +159,9 @@ static int filter_pred_##type(struct filter_pred *pred, void *event) \
case OP_GE: \
match = (*addr >= val); \
break; \
+ case OP_BAND: \
+ match = (*addr & val); \
+ break; \
default: \
break; \
} \
--
1.7.10.4
next prev parent reply other threads:[~2013-06-20 3:38 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-20 3:35 [for-next][PATCH 00/12] tracing: Updates and minor fixes for 3.11 Steven Rostedt
2013-06-20 3:35 ` [for-next][PATCH 01/12] tracing: Add function probe to trigger a ftrace dump to console Steven Rostedt
2013-06-20 3:35 ` [for-next][PATCH 02/12] tracing: Add function probe to trigger a ftrace dump of current CPU trace Steven Rostedt
2013-06-20 3:35 ` [for-next][PATCH 03/12] tracing/trivial: Consolidate error return condition Steven Rostedt
2013-06-20 3:35 ` [for-next][PATCH 04/12] tracing: Fix file mode of free_buffer Steven Rostedt
2013-06-20 3:35 ` [for-next][PATCH 05/12] ftrace: Use schedule_on_each_cpu() as a heavy synchronize_sched() Steven Rostedt
2013-06-20 3:35 ` [for-next][PATCH 06/12] ftrace: Remove ftrace_regex_lseek() Steven Rostedt
2013-06-20 3:35 ` [for-next][PATCH 07/12] tracing: Do not call kmem_cache_free() on allocation failure Steven Rostedt
2013-06-20 3:35 ` Steven Rostedt [this message]
2013-06-20 8:09 ` [for-next][PATCH 08/12] tracing: Add binary & filter for events Arend van Spriel
2013-06-20 12:14 ` Steven Rostedt
2013-06-20 18:28 ` Arend van Spriel
2013-06-20 18:34 ` Steven Rostedt
2013-06-20 18:38 ` Steven Rostedt
2013-06-20 19:15 ` Arend van Spriel
2013-06-20 3:35 ` [for-next][PATCH 09/12] tracing: Update documentation on tracepoint glob matching Steven Rostedt
2013-06-20 3:35 ` [for-next][PATCH 10/12] tracing: Disable tracing on warning Steven Rostedt
2013-06-20 3:35 ` [for-next][PATCH 11/12] tracing/kprobes: Remove unnecessary checking of trace_probe_is_enabled Steven Rostedt
2013-06-20 3:35 ` [for-next][PATCH 12/12] ftrace: Fix stddev calculation in function profiler 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=20130620033639.723900482@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=arend@broadcom.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).