Store multiplier and shift, required for TSC clock to nanosecond conversion in the metadata of the trace file. Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@xxxxxxxxx> --- tracecmd/trace-record.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c index 15521d0d..1313af03 100644 --- a/tracecmd/trace-record.c +++ b/tracecmd/trace-record.c @@ -666,6 +666,17 @@ static void delete_thread_data(void) } } +static void +add_tsc2nsec(struct tracecmd_output *handle, struct buffer_instance *instance) +{ + int array[] = { instance->tsc2nsec.mult, + instance->tsc2nsec.shift, + instance->tsc2nsec.offset}; + + tracecmd_add_option(handle, TRACECMD_OPTION_TSC2NSEC, + sizeof(array), array); +} + static void host_tsync_complete(struct buffer_instance *instance) { struct tracecmd_output *handle = NULL; @@ -680,6 +691,16 @@ static void host_tsync_complete(struct buffer_instance *instance) handle = tracecmd_get_output_handle_fd(fd); if (!handle) die("cannot create output handle"); + + /* + * If TSC is used as current trace clock and there is + * information for tsc to nanosecond conversion, store it + * in the trace file + */ + if (instance->tsc2nsec.mult && instance->clock && + !strncmp(top_instance.clock, TSC_CLOCK, strlen(TSC_CLOCK))) + add_tsc2nsec(handle, instance); + tracecmd_write_guest_time_shift(handle, instance->tsync); tracecmd_append_options(handle); tracecmd_output_close(handle); @@ -4269,6 +4290,15 @@ static void record_data(struct common_record_context *ctx) add_guest_info(handle, instance); } + /* + * If TSC is used as current trace clock and there is + * information for tsc to nanosecond conversion, store it + * in the trace file + */ + if (top_instance.tsc2nsec.mult && top_instance.clock && + !strncmp(top_instance.clock, TSC_CLOCK, strlen(TSC_CLOCK))) + add_tsc2nsec(handle, &top_instance); + if (tracecmd_write_cmdlines(handle)) die("Writing cmdlines"); -- 2.29.2