trace-cmd: Fix clock setting of agent proxy
cover trace-cmd: Fix clock setting of agent proxy
From: "Steven Rostedt (Google)" <[email protected]>
trace-cmd record does not set its clock to TSC if it connects to a agent proxy, when it should. This breaks the synchronization. It works if the user manually sets the clock to TSC before running the record, but the user should not need to do that.
Also, if the TSC2NSEC option is set, then print the timing out in seconds (with fractions) instead of the time stamp in nanoseconcds.
Steven Rostedt (Google) (2):
trace-cmd library: Keep USECS flag if TSC multiplier is set trace-cmd record: Set clock to TSC when connecting to a proxy with kvm
lib/trace-cmd/trace-input.c | 6 ++++++ tracecmd/trace-record.c | 13 +++++++++++++ 2 files changed, 19 insertions(+)
Signature · 1 line
2.35.1
PATCH 1/2 trace-cmd library: Keep USECS flag if TSC multiplier is set
From: "Steven Rostedt (Google)" <[email protected]>
If the option TSC2NSECS is set, then display as microseconds like it does with trace clock local. This is because even though the x86-tsc is not in nanoseconds, the clock will be shifted and multiplied to be in nanoseconds, so it makes sense to convert it to seconds.
--- lib/trace-cmd/trace-input.c | 6 ++++++ 1 file changed, 6 insertions(+)
lib/trace-cmd/trace-input.c +6 -0
@@ -3483,6 +3483,8 @@ static int handle_options(struct tracecmd_input *handle) buf + 4, 4); handle->tsc_calc.offset =tep_read_number (handle->pevent, buf +8 ,8 ); +if (!(handle->flags &TRACECMD_FL_RAW_TS )) + handle->flags |=TRACECMD_FL_IN_USECS ;break ;case TRACECMD_OPTION_HEADER_INFO :case TRACECMD_OPTION_FTRACE_EVENTS :
@@ -3865,6 +3867,10 @@ static void extract_trace_clock(struct tracecmd_input *handle, char *line)if (handle->flags &TRACECMD_FL_RAW_TS ) handle->flags &= ~TRACECMD_FL_IN_USECS ; +/* tsc_calc is a conversion to nanoseconds */ +if (handle->tsc_calc.mult) +return ; +/* Clear usecs if not one of the specified clocks */ if (strcmp(clock, "local") && strcmp(clock, "global") && strcmp(clock, "uptime") && strcmp(clock, "perf") &&
Signature · 1 line
2.35.1
PATCH 2/2 trace-cmd record: Set clock to TSC when connecting to a proxy with kvm
In reply to Steven RostedtFrom: "Steven Rostedt (Google)" <[email protected]>
If the time synchronization protocol for the recorder to a agent proxy is KVM, then it means that the TSC clock must be used. Force it when this is discovered.
--- tracecmd/trace-record.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
tracecmd/trace-record.c +13 -0
@@ -3849,16 +3849,29 @@ static int open_guest_fifos(const char *guest, int **fds)return i; } +static bool clock_is_supported (struct tracefs_instance *instance,const char *clock); +static int host_tsync (struct common_record_context *ctx,struct buffer_instance *instance,unsigned int tsync_port,char *proto) { +struct buffer_instance *iter_instance;int guest_id =-1 ;int fd;if (!proto)return -1 ; +/* If connecting to a proxy, the clock may still need to be set */ +if (strcmp (proto,"kvm" ) ==0 && +clock_is_supported (NULL ,TSC_CLOCK )) { + ctx->clock =TSC_CLOCK ; +for_all_instances (iter_instance) { + iter_instance->clock =TSC_CLOCK ; +set_clock (ctx, iter_instance); + } + } +if (is_network (instance)) { fd =connect_port (instance->name, tsync_port, instance->port_type);
Signature · 1 line
2.35.1