* [PATCH 0/2][GIT PULL] tracing/filters: adjustements for strings
@ 2009-05-03 1:50 Frederic Weisbecker
2009-05-03 1:50 ` [PATCH 1/2] tracing/filters: support for filters of dynamic sized arrays Frederic Weisbecker
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Frederic Weisbecker @ 2009-05-03 1:50 UTC (permalink / raw)
To: Ingo Molnar
Cc: LKML, Frederic Weisbecker, Tom Zanussi, Steven Rostedt, Li Zefan,
Zhaolei
Hi,
The following patchset includes two little peas of features
for tracing filters, making them able to filter every kind of strings.
Now I can do this:
cd /debug/tracing
echo > trace
echo stacktrace > trace_options
cd events/lockdep
echo 'name == "&REISERFS_SB(s)->lock" && wait_usec > 0' > lock_acquired/filter
echo 1 > lock_acquired/enable
sleep 1
echo 0 > lock_acquired/enable
cat trace
# tracer: nop
#
# TASK-PID CPU# TIMESTAMP FUNCTION
# | | | | |
<...>-6464 [000] 327.448232: lock_acquired: &REISERFS_SB(s)->lock (25058.984 us)
<...>-6464 [000] 327.448233:
<= reiserfs_get_block
<= __block_prepare_write
<= block_write_begin
<= reiserfs_write_begin
<= generic_file_buffered_write
<= __generic_file_aio_write_nolock
<= generic_file_aio_write
<...>-6470 [000] 327.448422: lock_acquired: &REISERFS_SB(s)->lock (25112.702 us)
<...>-6470 [000] 327.448425:
<= reiserfs_update_sd_size
<= reiserfs_write_end
<= generic_file_buffered_write
<= __generic_file_aio_write_nolock
<= generic_file_aio_write
<= do_sync_write
<= reiserfs_file_write
Tom, your filter framework is awesome and very useful!
Thanks :-)
Frederic.
---
The following changes since commit a0e39ed378fb6ba916522764cd508fa7d42ad495:
Heiko Carstens (1):
tracing: fix build failure on s390
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git tracing/filters
Frederic Weisbecker (2):
tracing/filters: support for filters of dynamic sized arrays
tracing/filters: support for operator reserved characters in strings
kernel/trace/trace_events_filter.c | 54 ++++++++++++++++++++++++++++++++++--
1 files changed, 51 insertions(+), 3 deletions(-)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] tracing/filters: support for filters of dynamic sized arrays
2009-05-03 1:50 [PATCH 0/2][GIT PULL] tracing/filters: adjustements for strings Frederic Weisbecker
@ 2009-05-03 1:50 ` Frederic Weisbecker
2009-05-03 1:50 ` [PATCH 2/2] tracing/filters: support for operator reserved characters in strings Frederic Weisbecker
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Frederic Weisbecker @ 2009-05-03 1:50 UTC (permalink / raw)
To: Ingo Molnar
Cc: LKML, Frederic Weisbecker, Tom Zanussi, Steven Rostedt, Li Zefan,
Zhaolei
Currently the filtering infrastructure supports well the
numeric types and fixed sized array types.
But the recently added __string() field uses a specific
indirect offset mechanism which requires a specific
predicate. Until now it wasn't supported.
This patch adds this support and implies very few changes,
only a new predicate is needed, the management of this specific
field can be done through the usual string helpers in the
filtering infrastructure.
[ Impact: support all kinds of strings in the tracing filters ]
Cc: Tom Zanussi <tzanussi@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Zhaolei <zhaolei@cn.fujitsu.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
---
kernel/trace/trace_events_filter.c | 44 +++++++++++++++++++++++++++++++++--
1 files changed, 41 insertions(+), 3 deletions(-)
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index f494866..4f0a128 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -151,6 +151,7 @@ static int filter_pred_or(struct filter_pred *pred __attribute((unused)),
return val1 || val2;
}
+/* Filter predicate for fixed sized arrays of characters */
static int filter_pred_string(struct filter_pred *pred, void *event,
int val1, int val2)
{
@@ -164,6 +165,30 @@ static int filter_pred_string(struct filter_pred *pred, void *event,
return match;
}
+/*
+ * Filter predicate for dynamic sized arrays of characters.
+ * These are implemented through a list of strings at the end
+ * of the entry.
+ * Also each of these strings have a field in the entry which
+ * contains its offset from the beginning of the entry.
+ * We have then first to get this field, dereference it
+ * and add it to the address of the entry, and at last we have
+ * the address of the string.
+ */
+static int filter_pred_strloc(struct filter_pred *pred, void *event,
+ int val1, int val2)
+{
+ int str_loc = *(int *)(event + pred->offset);
+ char *addr = (char *)(event + str_loc);
+ int cmp, match;
+
+ cmp = strncmp(addr, pred->str_val, pred->str_len);
+
+ match = (!cmp) ^ pred->not;
+
+ return match;
+}
+
static int filter_pred_none(struct filter_pred *pred, void *event,
int val1, int val2)
{
@@ -436,10 +461,18 @@ static int filter_add_pred_fn(struct filter_parse_state *ps,
return 0;
}
+enum {
+ FILTER_STATIC_STRING = 1,
+ FILTER_DYN_STRING
+};
+
static int is_string_field(const char *type)
{
if (strchr(type, '[') && strstr(type, "char"))
- return 1;
+ return FILTER_STATIC_STRING;
+
+ if (!strcmp(type, "__str_loc"))
+ return FILTER_DYN_STRING;
return 0;
}
@@ -502,6 +535,7 @@ static int filter_add_pred(struct filter_parse_state *ps,
struct ftrace_event_field *field;
filter_pred_fn_t fn;
unsigned long long val;
+ int string_type;
pred->fn = filter_pred_none;
@@ -526,8 +560,12 @@ static int filter_add_pred(struct filter_parse_state *ps,
return -EINVAL;
}
- if (is_string_field(field->type)) {
- fn = filter_pred_string;
+ string_type = is_string_field(field->type);
+ if (string_type) {
+ if (string_type == FILTER_STATIC_STRING)
+ fn = filter_pred_string;
+ else
+ fn = filter_pred_strloc;
pred->str_len = field->size;
if (pred->op == OP_NE)
pred->not = 1;
--
1.6.2.3
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/2] tracing/filters: support for operator reserved characters in strings
2009-05-03 1:50 [PATCH 0/2][GIT PULL] tracing/filters: adjustements for strings Frederic Weisbecker
2009-05-03 1:50 ` [PATCH 1/2] tracing/filters: support for filters of dynamic sized arrays Frederic Weisbecker
@ 2009-05-03 1:50 ` Frederic Weisbecker
2009-05-03 8:26 ` [PATCH 0/2][GIT PULL] tracing/filters: adjustements for strings Ingo Molnar
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Frederic Weisbecker @ 2009-05-03 1:50 UTC (permalink / raw)
To: Ingo Molnar
Cc: LKML, Frederic Weisbecker, Tom Zanussi, Steven Rostedt, Li Zefan,
Zhaolei
When we set a filter for an event, such as:
echo "name == my_lock_name" > \
/debug/tracing/events/lockdep/lock_acquired/filter
then the following order of token type is parsed:
- space
- operator
- parentheses
- operand
Because the operators and parentheses have a higher precedence
than the operand characters, which is normal, then we can't
use any string containing such special characters:
()=<>!&|
To get this support and also avoid ambiguous intepretation from
the parser or the human, we can do it using double quotes so that
we keep the usual languages habits.
Then after this patch you can still declare string condition like
before:
echo name == myname
But if you want to compare against a string containing an operator
character, you can use double quotes:
echo 'name == "&myname"'
Don't forget to include the whole expression into single quotes or
the double ones will be eaten by echo.
[ Impact: support strings with special characters for tracing filters ]
Cc: Tom Zanussi <tzanussi@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Zhaolei <zhaolei@cn.fujitsu.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
---
kernel/trace/trace_events_filter.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index 4f0a128..ac30de3 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -839,10 +839,19 @@ static void postfix_clear(struct filter_parse_state *ps)
static int filter_parse(struct filter_parse_state *ps)
{
+ int in_string = 0;
int op, top_op;
char ch;
while ((ch = infix_next(ps))) {
+ if (ch == '"') {
+ in_string ^= 1;
+ continue;
+ }
+
+ if (in_string)
+ goto parse_operand;
+
if (isspace(ch))
continue;
@@ -896,6 +905,7 @@ static int filter_parse(struct filter_parse_state *ps)
}
continue;
}
+parse_operand:
if (append_operand_char(ps, ch)) {
parse_error(ps, FILT_ERR_OPERAND_TOO_LONG, 0);
return -EINVAL;
--
1.6.2.3
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2][GIT PULL] tracing/filters: adjustements for strings
2009-05-03 1:50 [PATCH 0/2][GIT PULL] tracing/filters: adjustements for strings Frederic Weisbecker
2009-05-03 1:50 ` [PATCH 1/2] tracing/filters: support for filters of dynamic sized arrays Frederic Weisbecker
2009-05-03 1:50 ` [PATCH 2/2] tracing/filters: support for operator reserved characters in strings Frederic Weisbecker
@ 2009-05-03 8:26 ` Ingo Molnar
2009-05-04 4:47 ` Tom Zanussi
2009-05-04 13:42 ` Steven Rostedt
4 siblings, 0 replies; 7+ messages in thread
From: Ingo Molnar @ 2009-05-03 8:26 UTC (permalink / raw)
To: Frederic Weisbecker; +Cc: LKML, Tom Zanussi, Steven Rostedt, Li Zefan, Zhaolei
* Frederic Weisbecker <fweisbec@gmail.com> wrote:
> Hi,
>
> The following patchset includes two little peas of features
> for tracing filters, making them able to filter every kind of strings.
>
> Now I can do this:
>
> cd /debug/tracing
> echo > trace
> echo stacktrace > trace_options
>
> cd events/lockdep
> echo 'name == "&REISERFS_SB(s)->lock" && wait_usec > 0' > lock_acquired/filter
>
> echo 1 > lock_acquired/enable
> sleep 1
> echo 0 > lock_acquired/enable
>
> cat trace
>
> # tracer: nop
> #
> # TASK-PID CPU# TIMESTAMP FUNCTION
> # | | | | |
> <...>-6464 [000] 327.448232: lock_acquired: &REISERFS_SB(s)->lock (25058.984 us)
> <...>-6464 [000] 327.448233:
> <= reiserfs_get_block
> <= __block_prepare_write
> <= block_write_begin
> <= reiserfs_write_begin
> <= generic_file_buffered_write
> <= __generic_file_aio_write_nolock
> <= generic_file_aio_write
> <...>-6470 [000] 327.448422: lock_acquired: &REISERFS_SB(s)->lock (25112.702 us)
> <...>-6470 [000] 327.448425:
> <= reiserfs_update_sd_size
> <= reiserfs_write_end
> <= generic_file_buffered_write
> <= __generic_file_aio_write_nolock
> <= generic_file_aio_write
> <= do_sync_write
> <= reiserfs_file_write
>
>
> Tom, your filter framework is awesome and very useful!
> Thanks :-)
Seconded :)
>
> Frederic.
> ---
>
> The following changes since commit a0e39ed378fb6ba916522764cd508fa7d42ad495:
> Heiko Carstens (1):
> tracing: fix build failure on s390
>
> are available in the git repository at:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git tracing/filters
>
> Frederic Weisbecker (2):
> tracing/filters: support for filters of dynamic sized arrays
> tracing/filters: support for operator reserved characters in strings
>
> kernel/trace/trace_events_filter.c | 54 ++++++++++++++++++++++++++++++++++--
> 1 files changed, 51 insertions(+), 3 deletions(-)
Pulled, thanks Frederic!
Ingo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2][GIT PULL] tracing/filters: adjustements for strings
2009-05-03 1:50 [PATCH 0/2][GIT PULL] tracing/filters: adjustements for strings Frederic Weisbecker
` (2 preceding siblings ...)
2009-05-03 8:26 ` [PATCH 0/2][GIT PULL] tracing/filters: adjustements for strings Ingo Molnar
@ 2009-05-04 4:47 ` Tom Zanussi
2009-05-04 13:42 ` Steven Rostedt
4 siblings, 0 replies; 7+ messages in thread
From: Tom Zanussi @ 2009-05-04 4:47 UTC (permalink / raw)
To: Frederic Weisbecker; +Cc: Ingo Molnar, LKML, Steven Rostedt, Li Zefan, Zhaolei
Hi,
On Sun, 2009-05-03 at 03:50 +0200, Frederic Weisbecker wrote:
> Hi,
>
> The following patchset includes two little peas of features
> for tracing filters, making them able to filter every kind of strings.
>
> Now I can do this:
>
> cd /debug/tracing
> echo > trace
> echo stacktrace > trace_options
>
> cd events/lockdep
> echo 'name == "&REISERFS_SB(s)->lock" && wait_usec > 0' > lock_acquired/filter
>
> echo 1 > lock_acquired/enable
> sleep 1
> echo 0 > lock_acquired/enable
>
> cat trace
>
> # tracer: nop
> #
> # TASK-PID CPU# TIMESTAMP FUNCTION
> # | | | | |
> <...>-6464 [000] 327.448232: lock_acquired: &REISERFS_SB(s)->lock (25058.984 us)
> <...>-6464 [000] 327.448233:
> <= reiserfs_get_block
> <= __block_prepare_write
> <= block_write_begin
> <= reiserfs_write_begin
> <= generic_file_buffered_write
> <= __generic_file_aio_write_nolock
> <= generic_file_aio_write
> <...>-6470 [000] 327.448422: lock_acquired: &REISERFS_SB(s)->lock (25112.702 us)
> <...>-6470 [000] 327.448425:
> <= reiserfs_update_sd_size
> <= reiserfs_write_end
> <= generic_file_buffered_write
> <= __generic_file_aio_write_nolock
> <= generic_file_aio_write
> <= do_sync_write
> <= reiserfs_file_write
>
>
> Tom, your filter framework is awesome and very useful!
> Thanks :-)
Thanks! And thanks for adding these new useful features, too - the
patches look good to me...
Acked-by: Tom Zanussi <tzanussi@gmail.com>
Tom
>
> Frederic.
> ---
>
> The following changes since commit a0e39ed378fb6ba916522764cd508fa7d42ad495:
> Heiko Carstens (1):
> tracing: fix build failure on s390
>
> are available in the git repository at:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git tracing/filters
>
> Frederic Weisbecker (2):
> tracing/filters: support for filters of dynamic sized arrays
> tracing/filters: support for operator reserved characters in strings
>
> kernel/trace/trace_events_filter.c | 54 ++++++++++++++++++++++++++++++++++--
> 1 files changed, 51 insertions(+), 3 deletions(-)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2][GIT PULL] tracing/filters: adjustements for strings
2009-05-03 1:50 [PATCH 0/2][GIT PULL] tracing/filters: adjustements for strings Frederic Weisbecker
` (3 preceding siblings ...)
2009-05-04 4:47 ` Tom Zanussi
@ 2009-05-04 13:42 ` Steven Rostedt
2009-05-05 4:59 ` Tom Zanussi
4 siblings, 1 reply; 7+ messages in thread
From: Steven Rostedt @ 2009-05-04 13:42 UTC (permalink / raw)
To: Frederic Weisbecker
Cc: Ingo Molnar, LKML, Tom Zanussi, Li Zefan, Zhaolei, Theodore Tso
On Sun, 3 May 2009, Frederic Weisbecker wrote:
> Hi,
>
> The following patchset includes two little peas of features
> for tracing filters, making them able to filter every kind of strings.
>
> Now I can do this:
>
> cd /debug/tracing
> echo > trace
> echo stacktrace > trace_options
>
> cd events/lockdep
> echo 'name == "&REISERFS_SB(s)->lock" && wait_usec > 0' > lock_acquired/filter
>
> echo 1 > lock_acquired/enable
> sleep 1
> echo 0 > lock_acquired/enable
>
> cat trace
>
> # tracer: nop
> #
> # TASK-PID CPU# TIMESTAMP FUNCTION
> # | | | | |
> <...>-6464 [000] 327.448232: lock_acquired: &REISERFS_SB(s)->lock (25058.984 us)
> <...>-6464 [000] 327.448233:
> <= reiserfs_get_block
> <= __block_prepare_write
> <= block_write_begin
> <= reiserfs_write_begin
> <= generic_file_buffered_write
> <= __generic_file_aio_write_nolock
> <= generic_file_aio_write
> <...>-6470 [000] 327.448422: lock_acquired: &REISERFS_SB(s)->lock (25112.702 us)
> <...>-6470 [000] 327.448425:
> <= reiserfs_update_sd_size
> <= reiserfs_write_end
> <= generic_file_buffered_write
> <= __generic_file_aio_write_nolock
> <= generic_file_aio_write
> <= do_sync_write
> <= reiserfs_file_write
>
>
> Tom, your filter framework is awesome and very useful!
> Thanks :-)
I totally agree, and also like Frederic's changes.
But...
This is all useless unless people know it exists and more importantly, how
to use it.
Ted Tso already started a Documentation/trace/events.txt. We need to add
documentation of this feature either in Doc../trace/events.txt or add a
new file called Doc../trace/filters.txt. Probably would be better to add
a separate file, and add a "See filters.txt" in events.txt.
Tom or Frederic, could either of you write something up? I could when I
have time. The git logs seems to be pretty good at explaining it.
Thanks,
-- Steve
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2][GIT PULL] tracing/filters: adjustements for strings
2009-05-04 13:42 ` Steven Rostedt
@ 2009-05-05 4:59 ` Tom Zanussi
0 siblings, 0 replies; 7+ messages in thread
From: Tom Zanussi @ 2009-05-05 4:59 UTC (permalink / raw)
To: Steven Rostedt
Cc: Frederic Weisbecker, Ingo Molnar, LKML, Li Zefan, Zhaolei, Theodore Tso
Hi,
On Mon, 2009-05-04 at 09:42 -0400, Steven Rostedt wrote:
>
> On Sun, 3 May 2009, Frederic Weisbecker wrote:
>
> > Hi,
> >
> > The following patchset includes two little peas of features
> > for tracing filters, making them able to filter every kind of strings.
> >
> > Now I can do this:
> >
> > cd /debug/tracing
> > echo > trace
> > echo stacktrace > trace_options
> >
> > cd events/lockdep
> > echo 'name == "&REISERFS_SB(s)->lock" && wait_usec > 0' > lock_acquired/filter
> >
> > echo 1 > lock_acquired/enable
> > sleep 1
> > echo 0 > lock_acquired/enable
> >
> > cat trace
> >
> > # tracer: nop
> > #
> > # TASK-PID CPU# TIMESTAMP FUNCTION
> > # | | | | |
> > <...>-6464 [000] 327.448232: lock_acquired: &REISERFS_SB(s)->lock (25058.984 us)
> > <...>-6464 [000] 327.448233:
> > <= reiserfs_get_block
> > <= __block_prepare_write
> > <= block_write_begin
> > <= reiserfs_write_begin
> > <= generic_file_buffered_write
> > <= __generic_file_aio_write_nolock
> > <= generic_file_aio_write
> > <...>-6470 [000] 327.448422: lock_acquired: &REISERFS_SB(s)->lock (25112.702 us)
> > <...>-6470 [000] 327.448425:
> > <= reiserfs_update_sd_size
> > <= reiserfs_write_end
> > <= generic_file_buffered_write
> > <= __generic_file_aio_write_nolock
> > <= generic_file_aio_write
> > <= do_sync_write
> > <= reiserfs_file_write
> >
> >
> > Tom, your filter framework is awesome and very useful!
> > Thanks :-)
>
> I totally agree, and also like Frederic's changes.
>
> But...
>
>
> This is all useless unless people know it exists and more importantly, how
> to use it.
>
> Ted Tso already started a Documentation/trace/events.txt. We need to add
> documentation of this feature either in Doc../trace/events.txt or add a
> new file called Doc../trace/filters.txt. Probably would be better to add
> a separate file, and add a "See filters.txt" in events.txt.
>
> Tom or Frederic, could either of you write something up? I could when I
> have time. The git logs seems to be pretty good at explaining it.
>
Sure, I'll write something up and put it in Doc../trace/filters.txt.
Tom
> Thanks,
>
> -- Steve
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-05-05 4:59 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-03 1:50 [PATCH 0/2][GIT PULL] tracing/filters: adjustements for strings Frederic Weisbecker
2009-05-03 1:50 ` [PATCH 1/2] tracing/filters: support for filters of dynamic sized arrays Frederic Weisbecker
2009-05-03 1:50 ` [PATCH 2/2] tracing/filters: support for operator reserved characters in strings Frederic Weisbecker
2009-05-03 8:26 ` [PATCH 0/2][GIT PULL] tracing/filters: adjustements for strings Ingo Molnar
2009-05-04 4:47 ` Tom Zanussi
2009-05-04 13:42 ` Steven Rostedt
2009-05-05 4:59 ` Tom Zanussi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®