diff mbox series

[v2,60/87] trace-cmd report: Init the top trace instance earlier

Message ID 20210729050959.12263-61-tz.stoyanov@gmail.com (mailing list archive)
State Superseded
Headers show
Series Trace file version 7 | expand

Commit Message

Tzvetomir Stoyanov (VMware) July 29, 2021, 5:09 a.m. UTC
The instance must be initialized before calling the tracecmd_cpus() API,
as in trace files version 7, CPU count is set when the trace data are
initialized.

Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
 tracecmd/trace-read.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Steven Rostedt Aug. 19, 2021, 7:22 p.m. UTC | #1
On Thu, 29 Jul 2021 08:09:32 +0300
"Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com> wrote:

> The instance must be initialized before calling the tracecmd_cpus() API,
> as in trace files version 7, CPU count is set when the trace data are
> initialized.

This should have been an earlier patch.

-- Steve

> 
> Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
> ---
>  tracecmd/trace-read.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/tracecmd/trace-read.c b/tracecmd/trace-read.c
> index 1868a830..cafceffe 100644
> --- a/tracecmd/trace-read.c
> +++ b/tracecmd/trace-read.c
> @@ -1217,6 +1217,11 @@ static void read_data_info(struct list_head *handle_list, enum output_type otype
>  	list_for_each_entry(handles, handle_list, list) {
>  		int cpus;
>  
> +		if (!tracecmd_is_buffer_instance(handles->handle)) {
> +			ret = tracecmd_init_data(handles->handle);
> +			if (ret < 0)
> +				die("failed to init data");
> +		}
>  		cpus = tracecmd_cpus(handles->handle);
>  		handles->cpus = cpus;
>  		handles->last_timestamp = calloc(cpus, sizeof(*handles->last_timestamp));
> @@ -1227,9 +1232,6 @@ static void read_data_info(struct list_head *handle_list, enum output_type otype
>  		if (tracecmd_is_buffer_instance(handles->handle))
>  			continue;
>  
> -		ret = tracecmd_init_data(handles->handle);
> -		if (ret < 0)
> -			die("failed to init data");
>  		if (align_ts) {
>  			ts = tracecmd_get_first_ts(handles->handle);
>  			if (first || first_ts > ts)
diff mbox series

Patch

diff --git a/tracecmd/trace-read.c b/tracecmd/trace-read.c
index 1868a830..cafceffe 100644
--- a/tracecmd/trace-read.c
+++ b/tracecmd/trace-read.c
@@ -1217,6 +1217,11 @@  static void read_data_info(struct list_head *handle_list, enum output_type otype
 	list_for_each_entry(handles, handle_list, list) {
 		int cpus;
 
+		if (!tracecmd_is_buffer_instance(handles->handle)) {
+			ret = tracecmd_init_data(handles->handle);
+			if (ret < 0)
+				die("failed to init data");
+		}
 		cpus = tracecmd_cpus(handles->handle);
 		handles->cpus = cpus;
 		handles->last_timestamp = calloc(cpus, sizeof(*handles->last_timestamp));
@@ -1227,9 +1232,6 @@  static void read_data_info(struct list_head *handle_list, enum output_type otype
 		if (tracecmd_is_buffer_instance(handles->handle))
 			continue;
 
-		ret = tracecmd_init_data(handles->handle);
-		if (ret < 0)
-			die("failed to init data");
 		if (align_ts) {
 			ts = tracecmd_get_first_ts(handles->handle);
 			if (first || first_ts > ts)