[PATCH 1/2] trace-cmd record: Allow tracecmd_write_cpu_data() be called multiple times

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Steven Rostedt (VMware)" <rostedt@xxxxxxxxxxx>

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@xxxxxxxxxxx>
---
 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





[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux