diff options
author | Steven Rostedt <rostedt@goodmis.org> | 2013-06-12 13:16:25 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2013-06-19 23:30:40 -0400 |
commit | 1a891cf19cdfb645827969cc6aeaeebdefeb87b2 (patch) | |
tree | 7f62a3cd802158e8c29a6fdac1a54f39ba47a454 /kernel | |
parent | aaf6ac0f0871cb7fc0f28f3a00edf329bc7adc29 (diff) |
tracing: Add binary '&' filter for events
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>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/trace/trace_events_filter.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c index e1b653f7e1ca..0d883dc057d6 100644 --- a/kernel/trace/trace_events_filter.c +++ b/kernel/trace/trace_events_filter.c | |||
@@ -44,6 +44,7 @@ enum filter_op_ids | |||
44 | OP_LE, | 44 | OP_LE, |
45 | OP_GT, | 45 | OP_GT, |
46 | OP_GE, | 46 | OP_GE, |
47 | OP_BAND, | ||
47 | OP_NONE, | 48 | OP_NONE, |
48 | OP_OPEN_PAREN, | 49 | OP_OPEN_PAREN, |
49 | }; | 50 | }; |
@@ -54,6 +55,7 @@ struct filter_op { | |||
54 | int precedence; | 55 | int precedence; |
55 | }; | 56 | }; |
56 | 57 | ||
58 | /* Order must be the same as enum filter_op_ids above */ | ||
57 | static struct filter_op filter_ops[] = { | 59 | static struct filter_op filter_ops[] = { |
58 | { OP_OR, "||", 1 }, | 60 | { OP_OR, "||", 1 }, |
59 | { OP_AND, "&&", 2 }, | 61 | { OP_AND, "&&", 2 }, |
@@ -64,6 +66,7 @@ static struct filter_op filter_ops[] = { | |||
64 | { OP_LE, "<=", 5 }, | 66 | { OP_LE, "<=", 5 }, |
65 | { OP_GT, ">", 5 }, | 67 | { OP_GT, ">", 5 }, |
66 | { OP_GE, ">=", 5 }, | 68 | { OP_GE, ">=", 5 }, |
69 | { OP_BAND, "&", 6 }, | ||
67 | { OP_NONE, "OP_NONE", 0 }, | 70 | { OP_NONE, "OP_NONE", 0 }, |
68 | { OP_OPEN_PAREN, "(", 0 }, | 71 | { OP_OPEN_PAREN, "(", 0 }, |
69 | }; | 72 | }; |
@@ -156,6 +159,9 @@ static int filter_pred_##type(struct filter_pred *pred, void *event) \ | |||
156 | case OP_GE: \ | 159 | case OP_GE: \ |
157 | match = (*addr >= val); \ | 160 | match = (*addr >= val); \ |
158 | break; \ | 161 | break; \ |
162 | case OP_BAND: \ | ||
163 | match = (*addr & val); \ | ||
164 | break; \ | ||
159 | default: \ | 165 | default: \ |
160 | break; \ | 166 | break; \ |
161 | } \ | 167 | } \ |