From: Steven Rostedt <rostedt@goodmis.org>
To: linux-trace-devel@vger.kernel.org
Subject: [PATCH 1/2] trace-cmd record: Allow tracecmd_write_cpu_data() be called multiple times
Date: Fri, 05 Mar 2021 17:47:20 -0500 [thread overview]
Message-ID: <20210305224750.200301765@goodmis.org> (raw)
In-Reply-To: 20210305224719.784797597@goodmis.org
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
When trace-cmd record -B foo is executed, buffers for instances are recorded
in the trace.dat file by calling tracecmd_write_cpu_data() multiple times
(for toplevel and once for each instance). But currently the verification
code fails on the second call as it expects the state to be the previous
state. Allow this call to happen when the state is already set to
TRACECMD_FILE_CPU_FLYRECORD.
Fixes: 3717bb92a ("trace-cmd: Add validation for reading and writing trace.dat files")
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
lib/trace-cmd/trace-output.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/trace-cmd/trace-output.c b/lib/trace-cmd/trace-output.c
index c8f8a106c295..a2d4a16e3c3d 100644
--- a/lib/trace-cmd/trace-output.c
+++ b/lib/trace-cmd/trace-output.c
@@ -1339,7 +1339,9 @@ int tracecmd_write_cpu_data(struct tracecmd_output *handle,
int ret;
int i;
- ret = check_out_state(handle, TRACECMD_FILE_CPU_FLYRECORD);
+ /* This can be called multiple times (when recording instances) */
+ ret = handle->file_state == TRACECMD_FILE_CPU_FLYRECORD ? 0 :
+ check_out_state(handle, TRACECMD_FILE_CPU_FLYRECORD);
if (ret < 0) {
warning("Cannot write trace data into the file, unexpected state 0x%X",
handle->file_state);
--
2.30.0
next prev parent reply other threads:[~2021-03-05 22:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-05 22:47 [PATCH 0/2] trace-cmd: Fixes for instance recording and reporting Steven Rostedt
2021-03-05 22:47 ` Steven Rostedt [this message]
2021-03-05 22:47 ` [PATCH 2/2] trace-cmd report: Add last_timestamp array for instances 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=20210305224750.200301765@goodmis.org \
--to=rostedt@goodmis.org \
--cc=linux-trace-devel@vger.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).