@@ -1287,6 +1287,19 @@ static unsigned long long timestamp_correct(unsigned long long ts, int cpu,
&tsync->ts_samples[mid+1]);
}
+static unsigned long long timestamp_calc(unsigned long long ts, int cpu,
+ struct tracecmd_input *handle)
+{
+ unsigned long long tstamp;
+
+ tstamp = timestamp_correct(ts, cpu, handle);
+
+ if (handle->ts2secs)
+ tstamp *= handle->ts2secs;
+
+ return tstamp;
+}
+
/*
* Page is mapped, now read in the page header info.
*/
@@ -1308,11 +1321,8 @@ static int update_page_info(struct tracecmd_input *handle, int cpu)
kbuffer_subbuffer_size(kbuf));
return -1;
}
- handle->cpu_data[cpu].timestamp = timestamp_correct(kbuffer_timestamp(kbuf),
- cpu, handle);
-
- if (handle->ts2secs)
- handle->cpu_data[cpu].timestamp *= handle->ts2secs;
+ handle->cpu_data[cpu].timestamp = timestamp_calc(kbuffer_timestamp(kbuf),
+ cpu, handle);
return 0;
}
@@ -1942,10 +1952,7 @@ read_again:
goto read_again;
}
- handle->cpu_data[cpu].timestamp = timestamp_correct(ts, cpu, handle);
-
- if (handle->ts2secs)
- handle->cpu_data[cpu].timestamp *= handle->ts2secs;
+ handle->cpu_data[cpu].timestamp = timestamp_calc(ts, cpu, handle);
index = kbuffer_curr_offset(kbuf);
When reading event timestamps from a trace file, there could be various corrections depending on the metadata information from the file. Move all logic that performs timestamp calculations in a single function. Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com> --- lib/trace-cmd/trace-input.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-)