linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] trace-cmd: Fixes for instance recording and reporting
@ 2021-03-05 22:47 Steven Rostedt
  2021-03-05 22:47 ` [PATCH 1/2] trace-cmd record: Allow tracecmd_write_cpu_data() be called multiple times Steven Rostedt
  2021-03-05 22:47 ` [PATCH 2/2] trace-cmd report: Add last_timestamp array for instances Steven Rostedt
  0 siblings, 2 replies; 3+ messages in thread
From: Steven Rostedt @ 2021-03-05 22:47 UTC (permalink / raw)
  To: linux-trace-devel

It appears that the valification code broke instances.

Steven Rostedt (VMware) (2):
      trace-cmd record: Allow tracecmd_write_cpu_data() be called multiple times
      trace-cmd report: Add last_timestamp array for instances

----
 lib/trace-cmd/trace-output.c |  4 +++-
 tracecmd/trace-read.c        | 12 ++++++------
 2 files changed, 9 insertions(+), 7 deletions(-)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] trace-cmd record: Allow tracecmd_write_cpu_data() be called multiple times
  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
  2021-03-05 22:47 ` [PATCH 2/2] trace-cmd report: Add last_timestamp array for instances Steven Rostedt
  1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2021-03-05 22:47 UTC (permalink / raw)
  To: linux-trace-devel

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



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] trace-cmd report: Add last_timestamp array for instances
  2021-03-05 22:47 [PATCH 0/2] trace-cmd: Fixes for instance recording and reporting Steven Rostedt
  2021-03-05 22:47 ` [PATCH 1/2] trace-cmd record: Allow tracecmd_write_cpu_data() be called multiple times Steven Rostedt
@ 2021-03-05 22:47 ` Steven Rostedt
  1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2021-03-05 22:47 UTC (permalink / raw)
  To: linux-trace-devel

From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

The logic to add a last_timestamp array to the reading of trace data for
multiple files failed to include the array for instances within a given
file. This caused the instance handles not to have a way to save the last
timestamp, and caused the output to quit due to reading a record on a CPU
past the last CPU in the last_timestamp array.

Fixes: db36a61d2 ("trace-cmd: Fix last_timestamp logic to handle multiple files")
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 tracecmd/trace-read.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tracecmd/trace-read.c b/tracecmd/trace-read.c
index ce07b6bdb143..56fc0626d486 100644
--- a/tracecmd/trace-read.c
+++ b/tracecmd/trace-read.c
@@ -1205,6 +1205,12 @@ static void read_data_info(struct list_head *handle_list, enum output_type otype
 	list_for_each_entry(handles, handle_list, list) {
 		int cpus;
 
+		cpus = tracecmd_cpus(handles->handle);
+		handles->cpus = cpus;
+		handles->last_timestamp = calloc(cpus, sizeof(*handles->last_timestamp));
+		if (!handles->last_timestamp)
+			die("allocating timestamps");
+
 		/* Don't process instances that we added here */
 		if (tracecmd_is_buffer_instance(handles->handle))
 			continue;
@@ -1213,15 +1219,9 @@ static void read_data_info(struct list_head *handle_list, enum output_type otype
 		if (ret < 0)
 			die("failed to init data");
 
-		cpus = tracecmd_cpus(handles->handle);
-		handles->cpus = cpus;
 		print_handle_file(handles);
 		printf("cpus=%d\n", cpus);
 
-		handles->last_timestamp = calloc(cpus, sizeof(*handles->last_timestamp));
-		if (!handles->last_timestamp)
-			die("allocating timestamps");
-
 		/* Latency trace is just all ASCII */
 		if (ret > 0) {
 			if (multi_inputs)
-- 
2.30.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-05 22:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-05 22:47 [PATCH 0/2] trace-cmd: Fixes for instance recording and reporting Steven Rostedt
2021-03-05 22:47 ` [PATCH 1/2] trace-cmd record: Allow tracecmd_write_cpu_data() be called multiple times Steven Rostedt
2021-03-05 22:47 ` [PATCH 2/2] trace-cmd report: Add last_timestamp array for instances 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).