From: Steven Rostedt <rostedt@goodmis.org>
To: Linux Trace Devel <linux-trace-devel@vger.kernel.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Subject: [PATCH] trace-cmd: Do not print stacks after stacks
Date: Tue, 28 May 2024 11:31:41 -0400 [thread overview]
Message-ID: <20240528113141.7a3e8a04@rorschach.local.home> (raw)
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
When a filter is in place, the stack trace for the events that are
printed by the filter should also be printed. Stack traces for events
that are filtered out, should also be filtered out. But there was a bug
in the logic that checked if the last event was printed or not to know
to print the stack, and that is, the stack from the printed event was
considered a printed event itself. So a stack trace coming from another
event could be considered "printed" if two stacks came back to back
(which can happen because of interrupts.
Note, this does mean that logic should be added to test for interrupts.
But that's another story.
Reported-by: Vlastimil Babka <vbabka@suse.cz>
Fixes: 82ed4a937 ("trace-cmd library: Add filtering logic for iterating events")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
lib/trace-cmd/trace-filter.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/trace-cmd/trace-filter.c b/lib/trace-cmd/trace-filter.c
index 1c8c07fc..99423223 100644
--- a/lib/trace-cmd/trace-filter.c
+++ b/lib/trace-cmd/trace-filter.c
@@ -47,6 +47,7 @@ static bool test_stacktraces(struct tracecmd_filter *filter, struct tep_record *
__hidden enum tracecmd_filters tracecmd_filter_match(struct tracecmd_filter *filter,
struct tep_record *record)
{
+ bool is_stack = false;
bool found = false;
int ret;
int i;
@@ -94,6 +95,8 @@ __hidden enum tracecmd_filters tracecmd_filter_match(struct tracecmd_filter *fil
/* If this is a stack trace and the last event was printed continue */
if (!test_stacktraces(filter, record))
return TRACECMD_FILTER_MISS;
+
+ is_stack = true;
}
found = false;
@@ -110,7 +113,7 @@ __hidden enum tracecmd_filters tracecmd_filter_match(struct tracecmd_filter *fil
}
if (filter->last_printed)
- filter->last_printed[record->cpu] = !found;
+ filter->last_printed[record->cpu] = !is_stack && !found;
return found ? TRACECMD_FILTER_MISS : TRACECMD_FILTER_MATCH;
}
--
2.43.0
next reply other threads:[~2024-05-28 15:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-28 15:31 Steven Rostedt [this message]
2024-06-04 15:12 ` [PATCH] trace-cmd: Do not print stacks after stacks Vlastimil Babka
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=20240528113141.7a3e8a04@rorschach.local.home \
--to=rostedt@goodmis.org \
--cc=linux-trace-devel@vger.kernel.org \
--cc=vbabka@suse.cz \
/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).