trace-cmd: Fixes for instance recording and reporting
cover trace-cmd: Fixes for instance recording and reporting
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(-)
PATCH 1/2 trace-cmd record: Allow tracecmd_write_cpu_data() be called multiple times
From: "Steven Rostedt (VMware)" <[email protected]>
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.
--- lib/trace-cmd/trace-output.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
lib/trace-cmd/trace-output.c +3 -1
@@ -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);
Signature · 1 line
2.30.0
PATCH 2/2 trace-cmd report: Add last_timestamp array for instances
In reply to Steven RostedtFrom: "Steven Rostedt (VMware)" <[email protected]>
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.
--- tracecmd/trace-read.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
tracecmd/trace-read.c +6 -6
@@ -1205,6 +1205,12 @@ static void read_data_info(struct list_head *handle_list, enum output_type otypelist_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 otypeif (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)
Signature · 1 line
2.30.0