* [PATCH trace-cmd v2 0/3] trace-cmd filtering
@ 2023-03-30 18:52 Gabriel Krisman Bertazi
2023-03-30 18:52 ` [PATCH trace-cmd v2 1/3] trace-cmd report: Ensure filter is applied to single input file Gabriel Krisman Bertazi
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Gabriel Krisman Bertazi @ 2023-03-30 18:52 UTC (permalink / raw)
To: rostedt; +Cc: linux-trace-devel, Gabriel Krisman Bertazi
Hi Steve,
This implements my fix to restore single input filtering behavior
(bz217038) and adds support for global filters, as you requested.
On another topic, a current behavior that seems weird in my opinion is
that the following negates the second filter as well.
"trace-cmd -i trace.dat.1 -v -F tp1 -i trace.dat.2 -F tp2"
I'd prefer that -v would apply only to the following -F. It'd allow me
to do:
"trace-cmd -v -F 'mm_page_alloc' -i trace.dat.1 -i trace.dat.2 ... \
-i trace.dat.10 -F 'mm_page_alloc:order==1'"
It obviously breaks the interface, so I didn't implement it here. Would
like to hear your input, though. We could have a new syntax:
"trace-cmd ! -F tp1 -F tp2 ! -F tp3"
Thanks,
Gabriel Krisman Bertazi (3):
trace-cmd report: Ensure filter is applied to single input file
trace-cmd-report: Support global filters
documentation: trace-cmd-report: Document filter scope
.../trace-cmd/trace-cmd-report.1.txt | 8 +++-
tracecmd/trace-read.c | 45 ++++++++++++-------
2 files changed, 34 insertions(+), 19 deletions(-)
--
2.40.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH trace-cmd v2 1/3] trace-cmd report: Ensure filter is applied to single input file
2023-03-30 18:52 [PATCH trace-cmd v2 0/3] trace-cmd filtering Gabriel Krisman Bertazi
@ 2023-03-30 18:52 ` Gabriel Krisman Bertazi
2023-03-30 18:52 ` [PATCH trace-cmd v2 2/3] trace-cmd-report: Support global filters Gabriel Krisman Bertazi
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Gabriel Krisman Bertazi @ 2023-03-30 18:52 UTC (permalink / raw)
To: rostedt; +Cc: linux-trace-devel, Gabriel Krisman Bertazi
Since 955d05fc7aee ("trace-cmd report: Make filter arguments match their
files"), the -F filtering is silently ignored when a trace file is
provided with -i and the filter comes after -i . The reason is that the
filter is now associated with input_files and not saved to the global
list only in this case, but process_filters still only checks the global
list when handles->input_file is not set.
Avoid this by checking last_input_file first, which always contains a
pointer to the correct filter in this case.
This was only lightly tested, using a single trace file.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=217038
Fixes: 955d05fc7aee ("trace-cmd report: Make filter arguments match their files")
Signed-off-by: Gabriel krisman Bertazi <krisman@suse.de>
---
Since v1:
- use rev. xmas tree for variable declaration (steve)
---
tracecmd/trace-read.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/tracecmd/trace-read.c b/tracecmd/trace-read.c
index 52ba818..6a872d7 100644
--- a/tracecmd/trace-read.c
+++ b/tracecmd/trace-read.c
@@ -564,14 +564,15 @@ static void make_pid_filter(struct tracecmd_input *handle,
static void process_filters(struct handle_list *handles)
{
+ struct input_files *input_file = handles->input_file ?: last_input_file;
struct tracecmd_filter *trace_filter;
struct filter_str *filter;
int filters = 0;
- make_pid_filter(handles->handle, handles->input_file);
+ make_pid_filter(handles->handle, input_file);
- if (handles->input_file)
- filter = handles->input_file->filter_str;
+ if (input_file)
+ filter = input_file->filter_str;
else
filter = filter_strings;
--
2.40.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH trace-cmd v2 2/3] trace-cmd-report: Support global filters
2023-03-30 18:52 [PATCH trace-cmd v2 0/3] trace-cmd filtering Gabriel Krisman Bertazi
2023-03-30 18:52 ` [PATCH trace-cmd v2 1/3] trace-cmd report: Ensure filter is applied to single input file Gabriel Krisman Bertazi
@ 2023-03-30 18:52 ` Gabriel Krisman Bertazi
2023-03-30 18:52 ` [PATCH trace-cmd v2 3/3] documentation: trace-cmd-report: Document filter scope Gabriel Krisman Bertazi
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Gabriel Krisman Bertazi @ 2023-03-30 18:52 UTC (permalink / raw)
To: rostedt; +Cc: linux-trace-devel, Gabriel Krisman Bertazi
When a filter is provided before an input file, consider it globally
applying to all traces:
i.e., the following will trace kernel_stack out of both traces instead
of only the first:
$ trace-cmd report -v -F kernel_stack -i trace1.dat -i trace2.dat
Filter order matters due to the order of processing. Always process
global filters first, which are likely more generic.
Signed-off-by: Gabriel Krisman Bertazi <krisman@suse.de>
---
tracecmd/trace-read.c | 42 ++++++++++++++++++++++++++----------------
1 file changed, 26 insertions(+), 16 deletions(-)
diff --git a/tracecmd/trace-read.c b/tracecmd/trace-read.c
index 6a872d7..f645c05 100644
--- a/tracecmd/trace-read.c
+++ b/tracecmd/trace-read.c
@@ -562,30 +562,40 @@ static void make_pid_filter(struct tracecmd_input *handle,
}
}
+static int __process_filters(struct tracecmd_input *handle,
+ struct filter_str *filters)
+{
+ struct tracecmd_filter *trace_filter;
+
+ for (; filters; filters = filters->next) {
+ trace_filter = tracecmd_filter_add(handle,
+ filters->filter,
+ filters->neg);
+ if (!trace_filter)
+ die("Failed to create event filter: %s",
+ filters->filter);
+ }
+
+ return !!filters;
+}
+
static void process_filters(struct handle_list *handles)
{
struct input_files *input_file = handles->input_file ?: last_input_file;
- struct tracecmd_filter *trace_filter;
- struct filter_str *filter;
- int filters = 0;
+ int added = 0;
make_pid_filter(handles->handle, input_file);
+ /*
+ * Order of filter processing matters. Apply the global filters
+ * before file-specific ones.
+ */
+ added += __process_filters(handles->handle, filter_strings);
if (input_file)
- filter = input_file->filter_str;
- else
- filter = filter_strings;
-
- for (; filter; filter = filter->next) {
- trace_filter = tracecmd_filter_add(handles->handle,
- filter->filter,
- filter->neg);
- if (!trace_filter)
- die("Failed to create event filter: %s", filter->filter);
+ added += __process_filters(handles->handle,
+ input_file->filter_str);
- filters++;
- }
- if (filters && test_filters_mode)
+ if (added && test_filters_mode)
exit(0);
}
--
2.40.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH trace-cmd v2 3/3] documentation: trace-cmd-report: Document filter scope
2023-03-30 18:52 [PATCH trace-cmd v2 0/3] trace-cmd filtering Gabriel Krisman Bertazi
2023-03-30 18:52 ` [PATCH trace-cmd v2 1/3] trace-cmd report: Ensure filter is applied to single input file Gabriel Krisman Bertazi
2023-03-30 18:52 ` [PATCH trace-cmd v2 2/3] trace-cmd-report: Support global filters Gabriel Krisman Bertazi
@ 2023-03-30 18:52 ` Gabriel Krisman Bertazi
2023-05-06 22:35 ` [PATCH trace-cmd v2 0/3] trace-cmd filtering Gabriel Krisman Bertazi
2023-05-30 8:20 ` Steven Rostedt
4 siblings, 0 replies; 7+ messages in thread
From: Gabriel Krisman Bertazi @ 2023-03-30 18:52 UTC (permalink / raw)
To: rostedt; +Cc: linux-trace-devel, Gabriel Krisman Bertazi
Document how filters provided before any input files are global while
filters coming after a -i only apply to that filter.
Signed-off-by: Gabriel Krisman Bertazi <krisman@suse.de>
---
Documentation/trace-cmd/trace-cmd-report.1.txt | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/Documentation/trace-cmd/trace-cmd-report.1.txt b/Documentation/trace-cmd/trace-cmd-report.1.txt
index 71df9a8..ddbde81 100644
--- a/Documentation/trace-cmd/trace-cmd-report.1.txt
+++ b/Documentation/trace-cmd/trace-cmd-report.1.txt
@@ -69,8 +69,12 @@ OPTIONS
is only to the microsecond. To see the full timestamp, add the *-t* option.
*-F* 'filter'::
- Add a filter to limit what events are displayed. The format of the filter
- is:
+ Add a filter to limit what events are displayed. Filters defined
+ after an input file (specified with *-i*) only apply to that
+ input file. Filters provided before any input file is given are
+ considered global and apply to all input files.
+
+ The format of the filter is:
[source,bison]
----
--
2.40.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH trace-cmd v2 0/3] trace-cmd filtering
2023-03-30 18:52 [PATCH trace-cmd v2 0/3] trace-cmd filtering Gabriel Krisman Bertazi
` (2 preceding siblings ...)
2023-03-30 18:52 ` [PATCH trace-cmd v2 3/3] documentation: trace-cmd-report: Document filter scope Gabriel Krisman Bertazi
@ 2023-05-06 22:35 ` Gabriel Krisman Bertazi
2023-05-07 1:51 ` Steven Rostedt
2023-05-30 8:20 ` Steven Rostedt
4 siblings, 1 reply; 7+ messages in thread
From: Gabriel Krisman Bertazi @ 2023-05-06 22:35 UTC (permalink / raw)
To: rostedt; +Cc: linux-trace-devel
Gabriel Krisman Bertazi <krisman@suse.de> writes:
> Hi Steve,
I wanted to ping you regarding this patchset. Do you intend to take
this as-is?
Thanks!
>
> This implements my fix to restore single input filtering behavior
> (bz217038) and adds support for global filters, as you requested.
>
> On another topic, a current behavior that seems weird in my opinion is
> that the following negates the second filter as well.
>
> "trace-cmd -i trace.dat.1 -v -F tp1 -i trace.dat.2 -F tp2"
>
> I'd prefer that -v would apply only to the following -F. It'd allow me
> to do:
>
> "trace-cmd -v -F 'mm_page_alloc' -i trace.dat.1 -i trace.dat.2 ... \
> -i trace.dat.10 -F 'mm_page_alloc:order==1'"
>
> It obviously breaks the interface, so I didn't implement it here. Would
> like to hear your input, though. We could have a new syntax:
>
> "trace-cmd ! -F tp1 -F tp2 ! -F tp3"
>
> Thanks,
>
> Gabriel Krisman Bertazi (3):
> trace-cmd report: Ensure filter is applied to single input file
> trace-cmd-report: Support global filters
> documentation: trace-cmd-report: Document filter scope
>
> .../trace-cmd/trace-cmd-report.1.txt | 8 +++-
> tracecmd/trace-read.c | 45 ++++++++++++-------
> 2 files changed, 34 insertions(+), 19 deletions(-)
--
Gabriel Krisman Bertazi
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH trace-cmd v2 0/3] trace-cmd filtering
2023-05-06 22:35 ` [PATCH trace-cmd v2 0/3] trace-cmd filtering Gabriel Krisman Bertazi
@ 2023-05-07 1:51 ` Steven Rostedt
0 siblings, 0 replies; 7+ messages in thread
From: Steven Rostedt @ 2023-05-07 1:51 UTC (permalink / raw)
To: Gabriel Krisman Bertazi; +Cc: linux-trace-devel
On Sat, 06 May 2023 18:35:34 -0400
Gabriel Krisman Bertazi <krisman@suse.de> wrote:
> Gabriel Krisman Bertazi <krisman@suse.de> writes:
>
> > Hi Steve,
>
> I wanted to ping you regarding this patchset. Do you intend to take
> this as-is?
>
Apologies, I've been mostly focused on the kernel the last few weeks,
but as I'm giving a talk on the tracing libraries on Thursday, I'll be
focusing on them now ;-)
https://ossna2023.sched.com/event/1K58e
So I'll reply in a few days.
-- Steve
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH trace-cmd v2 0/3] trace-cmd filtering
2023-03-30 18:52 [PATCH trace-cmd v2 0/3] trace-cmd filtering Gabriel Krisman Bertazi
` (3 preceding siblings ...)
2023-05-06 22:35 ` [PATCH trace-cmd v2 0/3] trace-cmd filtering Gabriel Krisman Bertazi
@ 2023-05-30 8:20 ` Steven Rostedt
4 siblings, 0 replies; 7+ messages in thread
From: Steven Rostedt @ 2023-05-30 8:20 UTC (permalink / raw)
To: Gabriel Krisman Bertazi; +Cc: linux-trace-devel
On Thu, 30 Mar 2023 15:52:08 -0300
Gabriel Krisman Bertazi <krisman@suse.de> wrote:
> Hi Steve,
Hi Gabriel,
Sorry for taking so long. I finally got time to start looking at the
libtrace* trace-cmd code, and I queued this up for the next push.
Thanks Gabriel!
-- Steve
>
> This implements my fix to restore single input filtering behavior
> (bz217038) and adds support for global filters, as you requested.
>
> On another topic, a current behavior that seems weird in my opinion is
> that the following negates the second filter as well.
>
> "trace-cmd -i trace.dat.1 -v -F tp1 -i trace.dat.2 -F tp2"
>
> I'd prefer that -v would apply only to the following -F. It'd allow me
> to do:
>
> "trace-cmd -v -F 'mm_page_alloc' -i trace.dat.1 -i trace.dat.2 ... \
> -i trace.dat.10 -F 'mm_page_alloc:order==1'"
>
> It obviously breaks the interface, so I didn't implement it here. Would
> like to hear your input, though. We could have a new syntax:
>
> "trace-cmd ! -F tp1 -F tp2 ! -F tp3"
>
> Thanks,
>
> Gabriel Krisman Bertazi (3):
> trace-cmd report: Ensure filter is applied to single input file
> trace-cmd-report: Support global filters
> documentation: trace-cmd-report: Document filter scope
>
> .../trace-cmd/trace-cmd-report.1.txt | 8 +++-
> tracecmd/trace-read.c | 45 ++++++++++++-------
> 2 files changed, 34 insertions(+), 19 deletions(-)
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-05-30 8:20 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-30 18:52 [PATCH trace-cmd v2 0/3] trace-cmd filtering Gabriel Krisman Bertazi
2023-03-30 18:52 ` [PATCH trace-cmd v2 1/3] trace-cmd report: Ensure filter is applied to single input file Gabriel Krisman Bertazi
2023-03-30 18:52 ` [PATCH trace-cmd v2 2/3] trace-cmd-report: Support global filters Gabriel Krisman Bertazi
2023-03-30 18:52 ` [PATCH trace-cmd v2 3/3] documentation: trace-cmd-report: Document filter scope Gabriel Krisman Bertazi
2023-05-06 22:35 ` [PATCH trace-cmd v2 0/3] trace-cmd filtering Gabriel Krisman Bertazi
2023-05-07 1:51 ` Steven Rostedt
2023-05-30 8:20 ` Steven Rostedt
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).