trace-cmd: Timetamps sync between host and guest machines, relying on vsock events.
v11 cover trace-cmd: Timetamps sync between host and guest machines, relying on vsock events.
[
v11 changes:
- Rebased on top of Slavomir's v10 "Add VM kernel tracing over vsockets and FIFOs"
- Addressed Slavomir's commnents from version 10 of the patch series.
v10 changes:
- Fixed broken compilation, call to timestamp_correction_calc() in timestamp_correct was smashed.
- Replaced deprecated tep_data_event_from_type() API with tep_find_event().
- Fixed a warning on assignment const to non const.
v9 changes:
- Fixed implementation of binary search algorithm in timestamp_correct()
v8 changes:
- Added rmdir() call in tracecmd_remove_instance(), to completely remove the instance. However, there is an issue with deleting the instances using rmdir(), which is investigated.
- Few changes in read_qemu_guests_pids(), timestamp_correct(), tsync_offset_load()
tracecmd_clock_context_new() and find_raw_events() suggested by Slavomir.
v7 changes:
- Added warning messages in case time synchronization cannot be negotiated or fails.
- Few optimizations and checks in read_qemu_guests_pids(), tsync_offset_load(), and find_raw_events(), suggested by Slavomir Kaslev.
- Reworked timestamp_correct() to not use static variables.
- Check TRACECMD_OPTION_TIME_SHIFT before reading time sync samples from the trace.dat file
v6 changes:
- Refactored tracecmd_msg_snd_time_sync() and tracecmd_msg_rcv_time_sync() functions:
removed any time sync calculations logic as separate functions in trace-timesync.c file
- Defined TSYNC_PROBE, TSYNC_REQ and TSYNC_RESP messages, in order to make the time sync protocol comprehensible.
- Addressed Steven Rostedt comments.
- Addressed Slavomir Kaslev commnets.
v5 changes:
- Rebased to Slavomir's v8 "Add VM kernel tracing over vsockets and FIFOs" patch series.
- Implemented an algorithm for time drift correction.
- Addressed Slavomir's commnets.
- Refactored the code: moved all time sync specific implementation in trace-timesync.c
- Isolated all hardcoded event specific stuff in a structure, so it could be easily moved to external plugins.
- Added a check for VSOCK support: do not perform vsock dependent time synchronisation in case there is no VSOCK support.
v4 changes:
- Removed the implementation of PTP-like algorithm. The current logic relies on matching time stamps of kvm_exit/virtio_transport_recv_pkt events on host to virtio_transport_alloc_pkt/vp_notify events on guest.
- Rebased to Slavomir's v7 "Add VM kernel tracing over vsockets and FIFOs" patch series.
- Decreased the time synch probes from 5000 to 300.
- Addressed Steven Rostedt comments.
- Code cleanup.
v3 changes:
- Removed any magic constants, used in the PTP-like algorithm, as Slavomir Kaslev suggested.
- Implemented new algorithm, based on mapping kvm_exit events in host context to vsock_send events in guest context, suggested by Steven Rostedt.
v2 changes:
- Addressed Steven Rostedt comments.
- Modified PTP-like timestamps sync algorithm to gain more accuracy, with the help of Yordan Karadzhov and Slavomir Kaslev.
]
POC implementation of algorithm for timestamps sync between guest and host machines. The algorithm relies on matching time stamps of guest and host vsock events.
The patch series depends on Slavomir's changes, introduced by the v10 patch series "Add VM kernel tracing over vsockets and FIFOs"
Tzvetomir Stoyanov (9):
trace-cmd: Implemented new lib API: tracecmd_local_events_system()
trace-cmd: Added support for negative time offsets in trace.dat file
trace-cmd: Fix tracecmd_read_page_record() to read more than one event
trace-cmd: Added implementation of htonll() and ntohll()
trace-cmd: Refactored few functions in trace-record.c
trace-cmd: Find and store pids of tasks, which run virtual CPUs of
given VM
trace-cmd: Implemented new API tracecmd_add_option_v()
trace-cmd: Implemented new option in trace.dat file:
TRACECMD_OPTION_TIME_SHIFT
trace-cmd [POC]: Implemented timestamps synch algorithm, using vsock
events.
include/trace-cmd/trace-cmd.h | 31 +- include/traceevent/event-parse.h | 1 + lib/trace-cmd/trace-input.c | 145 +++++- lib/trace-cmd/trace-util.c | 98 ++-- tracecmd/Makefile | 1 + tracecmd/include/trace-local.h | 43 +- tracecmd/include/trace-msg.h | 10 + tracecmd/trace-agent.c | 13 +- tracecmd/trace-msg.c | 209 +++++++- tracecmd/trace-output.c | 117 ++++- tracecmd/trace-read.c | 4 +- tracecmd/trace-record.c | 229 +++++++-- tracecmd/trace-timesync.c | 808 +++++++++++++++++++++++++++++++ 13 files changed, 1575 insertions(+), 134 deletions(-) create mode 100644 tracecmd/trace-timesync.c
Signature · 1 line
2.20.1
PATCH v11 1/9 trace-cmd: Implemented new lib API: tracecmd_local_events_system()
The new tracecmd lib API tracecmd_local_events_system() creates a tep handler and initializes it with the events of the specified subsystems.
--- include/trace-cmd/trace-cmd.h | 2 + lib/trace-cmd/trace-util.c | 98 ++++++++++++++++++++++++----------- 2 files changed, 69 insertions(+), 31 deletions(-)
include/trace-cmd/trace-cmd.h +2 -0
@@ -32,6 +32,8 @@ void tracecmd_unload_plugins(struct tep_plugin_list *list, struct tep_handle *pechar **tracecmd_event_systems (const char *tracing_dir);char **tracecmd_system_events (const char *tracing_dir,const char *system);struct tep_handle *tracecmd_local_events (const char *tracing_dir); +struct tep_handle *tracecmd_local_events_system (const char *tracing_dir, +const char *const *sys_names);int tracecmd_fill_local_events (const char *tracing_dir,struct tep_handle *pevent,int *parsing_failures);char **tracecmd_local_plugins (const char *tracing_dir);
lib/trace-cmd/trace-util.c +67 -31
119 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v11 2/9 trace-cmd: Added support for negative time offsets in trace.dat file
In reply to Tzvetomir StoyanovWhen synchronizing timestamps between different machines, there are cases when the time offset is negative. This patch changes the way time offset is written and read from trace.dat file - as signed decimal, instead of hex.
--- include/trace-cmd/trace-cmd.h | 2 +- lib/trace-cmd/trace-input.c | 6 +++--- tracecmd/trace-read.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-)
include/trace-cmd/trace-cmd.h +1 -1
@@ -128,7 +128,7 @@ int tracecmd_is_buffer_instance(struct tracecmd_input *handle);void tracecmd_create_top_instance (char *name);void tracecmd_remove_instances (void ); -void tracecmd_set_ts_offset (struct tracecmd_input *handle,unsigned long long offset); +void tracecmd_set_ts_offset (struct tracecmd_input *handle,long long offset);void tracecmd_set_ts2secs (struct tracecmd_input *handle,unsigned long long hz);void tracecmd_print_events (struct tracecmd_input *handle,const char *regex);
lib/trace-cmd/trace-input.c +3 -3
@@ -91,7 +91,7 @@ struct tracecmd_input {bool read_page;bool use_pipe;struct cpu_data *cpu_data; -unsigned long long ts_offset; +long long ts_offset;double ts2secs;char * cpustats;char * uname;
@@ -2098,7 +2098,7 @@ static int init_cpu(struct tracecmd_input *handle, int cpu) }void tracecmd_set_ts_offset (struct tracecmd_input *handle, -unsigned long long offset) +long long offset) { handle->ts_offset = offset; }
@@ -2115,7 +2115,7 @@ void tracecmd_set_ts2secs(struct tracecmd_input *handle,static int handle_options (struct tracecmd_input *handle) { -unsigned long long offset; +long long offset;unsigned short option;unsigned int size;char *cpustats =NULL ;
tracecmd/trace-read.c +2 -2
@@ -58,7 +58,7 @@ static struct list_head handle_list;struct input_files {struct list_head list;const char *file; -unsigned long long tsoffset; +long long tsoffset;unsigned long long ts2secs; };static struct list_head input_files;
@@ -1418,7 +1418,7 @@ void trace_report (int argc, char **argv)struct input_files *inputs;struct handle_list *handles;enum output_type otype; -unsigned long long tsoffset =0 ; +long long tsoffset =0 ;unsigned long long ts2secs =0 ;unsigned long long ts2sc;int show_stat =0 ;
Signature · 1 line
2.20.1
PATCH v11 3/9 trace-cmd: Fix tracecmd_read_page_record() to read more than one event
In reply to Tzvetomir StoyanovThe kbuffer_next_event() will return the next event on the sub buffer. If we pass in the last_record to tracecmd_read_page_record(), it initializes the sub buffer, and by calling kbuffer_next_event() (instead of kbuffer_read_event()), the second event on the sub buffer is returned. This causes the match of the last_record not to match if the last_record happens to be the first event on the sub buffer.
--- lib/trace-cmd/trace-input.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
lib/trace-cmd/trace-input.c +8 -4
@@ -1695,18 +1695,22 @@ tracecmd_read_page_record(struct tep_handle *pevent, void *page, int size, goto out_free; } -do { + ptr =kbuffer_read_event (kbuf, &ts); +while (ptr < last_record->data) { ptr =kbuffer_next_event (kbuf,NULL );if (!ptr)break ; - }while (ptr < last_record->data); +if (ptr == last_record->data) +break ; + }if (ptr != last_record->data) {warning ("tracecmd_read_page_record: could not find last_record" ); goto out_free; } - } + ptr =kbuffer_next_event (kbuf, &ts); + }else + ptr =kbuffer_read_event (kbuf, &ts); - ptr =kbuffer_read_event (kbuf, &ts);if (!ptr) goto out_free;
Signature · 1 line
2.20.1
PATCH v11 4/9 trace-cmd: Added implementation of htonll() and ntohll()
In reply to Tzvetomir StoyanovAdded implementation of htonll() and ntohll() as
macros, if they are not already defined.
--- tracecmd/include/trace-msg.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
tracecmd/include/trace-msg.h +10 -0
@@ -15,4 +15,14 @@ extern unsigned int page_size;void plog (const char *fmt, ...);void pdie (const char *fmt, ...); +#ifndef htonll +# if __BYTE_ORDER == __LITTLE_ENDIAN +#define htonll (x) __bswap_64(x) +#define ntohll (x) __bswap_64(x) +#else +#define htonll (x) (x) +#define ntohll (x) (x) +#endif +#endif +#endif /* _TRACE_MSG_H_ */
Signature · 1 line
2.20.1
PATCH v11 5/9 trace-cmd: Refactored few functions in trace-record.c
In reply to Tzvetomir StoyanovIn order to reuse the code inside the trace-cmd application, few functions from trace-record.c are refactored:
- make_instances() and tracecmd_remove_instances() are splited.
New ones are created: tracecmd_make_instance() and tracecmd_remove_instance(), which are visible outside the trace-record.c
- Following functions are made non-static: tracecmd_init_instance()get_instance_dir(), write_instance_file(), write_tracing_on(), tracecmd_set_clock()
- New function is implemented: tracecmd_local_cpu_count(), an internal
API to get local_cpu_count.
--- tracecmd/include/trace-local.h | 9 ++++ tracecmd/trace-record.c | 88 +++++++++++++++++++--------------- 2 files changed, 59 insertions(+), 38 deletions(-)
tracecmd/include/trace-local.h +9 -0
@@ -235,6 +235,15 @@ void update_first_instance(struct buffer_instance *instance, int topt);void show_instance_file (struct buffer_instance *instance,const char *name);int count_cpus (void ); +void write_tracing_on (struct buffer_instance *instance,int on); +char *get_instance_dir (struct buffer_instance *instance); +int write_instance_file (struct buffer_instance *instance, +const char *file,const char *str,const char *type); +void tracecmd_init_instance (struct buffer_instance *instance); +void tracecmd_make_instance (struct buffer_instance *instance); +int tracecmd_local_cpu_count (void ); +void tracecmd_set_clock (struct buffer_instance *instance); +void tracecmd_remove_instance (struct buffer_instance *instance);/* No longer in event-utils.h */ void __noreturn die (const char *fmt, ...);/* Can be overriden */
tracecmd/trace-record.c +50 -38
190 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v11 6/9 trace-cmd: Find and store pids of tasks, which run virtual CPUs of given VM
In reply to Tzvetomir StoyanovIn order to match host and guest events, a mapping between guest VCPU and the host task, running this VCPU is needed. Extended existing struct guest to hold such mapping and added logic in read_qemu_guests() function to initialize it. Implemented a new internal API, get_guest_vcpu_pid(), to retrieve VCPU-task mapping for given VM.
--- tracecmd/include/trace-local.h | 1 + tracecmd/trace-record.c | 57 ++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+)
tracecmd/include/trace-local.h +1 -0
@@ -245,6 +245,7 @@ int tracecmd_local_cpu_count(void);void tracecmd_set_clock (struct buffer_instance *instance);void tracecmd_remove_instance (struct buffer_instance *instance); +int get_guest_vcpu_pid (unsigned int guest_cid,unsigned int guest_vcpu);/* No longer in event-utils.h */ void __noreturn die (const char *fmt, ...);/* Can be overriden */ void *malloc_or_die (unsigned int size);/* Can be overridden */
tracecmd/trace-record.c +57 -0
85 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v11 7/9 trace-cmd: Implemented new API tracecmd_add_option_v()
In reply to Tzvetomir StoyanovThis patch implements a new tracecmd API, tracecmd_add_option_v() It adds new option in trace.dat, similar to tracecmd_add_option(), but the option's data is passed as list of buffers. The standard struct iovec is used as input parameter, containing the option's data buffers.
--- include/trace-cmd/trace-cmd.h | 5 ++ include/traceevent/event-parse.h | 1 + tracecmd/trace-output.c | 117 ++++++++++++++++++++++++++----- 3 files changed, 106 insertions(+), 17 deletions(-)
include/trace-cmd/trace-cmd.h +5 -0
@@ -247,11 +247,16 @@ struct tracecmd_output *tracecmd_create_init_file_override(const char *output_fistruct tracecmd_option *tracecmd_add_option (struct tracecmd_output *handle,unsigned short id,int size,const void *data); +struct tracecmd_option * +tracecmd_add_option_v (struct tracecmd_output *handle, +unsigned short id,const struct iovec *vector,int count); +struct tracecmd_option *tracecmd_add_buffer_option (struct tracecmd_output *handle,const char *name,int cpus);int tracecmd_write_cpus (struct tracecmd_output *handle,int cpus);int tracecmd_write_options (struct tracecmd_output *handle); +int tracecmd_append_options (struct tracecmd_output *handle);int tracecmd_update_option (struct tracecmd_output *handle,struct tracecmd_option *option,int size,const void *data);
include/traceevent/event-parse.h +1 -0
@@ -11,6 +11,7 @@#include <stdio.h> #include <regex.h> #include <string.h> +#include <sys/uio.h> #include "trace-seq.h"
tracecmd/trace-output.c +100 -17
159 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v11 8/9 trace-cmd: Implemented new option in trace.dat file: TRACECMD_OPTION_TIME_SHIFT
In reply to Tzvetomir StoyanovThe TRACECMD_OPTION_TIME_SHIFT is used when synchronizing trace time stamps between two trace.dat files. It contains multiple long long (time, offset) pairs, describing time stamps _offset_, measured in the given local _time_. The content of the option buffer is:
first 4 bytes - integer, count of timestamp offsets
long long array of size _count_, local time in which the offset is measured long long array of size _count_, offset of the time stamps
--- include/trace-cmd/trace-cmd.h | 1 + lib/trace-cmd/trace-input.c | 127 +++++++++++++++++++++++++++++++++- 2 files changed, 126 insertions(+), 2 deletions(-)
include/trace-cmd/trace-cmd.h +1 -0
@@ -83,6 +83,7 @@ enum {TRACECMD_OPTION_HOOK ,TRACECMD_OPTION_OFFSET ,TRACECMD_OPTION_CPUCOUNT , + TRACECMD_OPTION_TIME_SHIFT, }; enum {
lib/trace-cmd/trace-input.c +125 -2
175 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v11 9/9 trace-cmd [POC]: Implemented timestamps synch algorithm, using vsock events.
In reply to Tzvetomir StoyanovThis is a POC patch, implementing an algorithm for syncing timestamps between host and guest machines, using vsock trace events to catch the host / guest time.
--- include/trace-cmd/trace-cmd.h | 21 +- tracecmd/Makefile | 1 + tracecmd/include/trace-local.h | 33 +- tracecmd/trace-agent.c | 13 +- tracecmd/trace-msg.c | 209 ++++++++- tracecmd/trace-record.c | 84 +++- tracecmd/trace-timesync.c | 808 +++++++++++++++++++++++++++++++++ 7 files changed, 1133 insertions(+), 36 deletions(-) create mode 100644 tracecmd/trace-timesync.c
include/trace-cmd/trace-cmd.h +17 -4
@@ -343,16 +343,29 @@ bool tracecmd_msg_done(struct tracecmd_msg_handle *msg_handle);void tracecmd_msg_set_done (struct tracecmd_msg_handle *msg_handle);int tracecmd_msg_send_trace_req (struct tracecmd_msg_handle *msg_handle, -int argc,char **argv,bool use_fifos); +int argc,char **argv,bool use_fifos, +bool do_tsync);int tracecmd_msg_recv_trace_req (struct tracecmd_msg_handle *msg_handle, -int *argc,char ***argv,bool *use_fifos); +int *argc,char ***argv,bool *use_fifos, +bool *do_tsync);int tracecmd_msg_send_trace_resp (struct tracecmd_msg_handle *msg_handle,int nr_cpus,int page_size, -unsigned int *ports,bool use_fifos); +unsigned int *ports,bool use_fifos, +bool do_tsync);int tracecmd_msg_recv_trace_resp (struct tracecmd_msg_handle *msg_handle,int *nr_cpus,int *page_size, -unsigned int **ports,bool *use_fifos); +unsigned int **ports,bool *use_fifos, +bool *do_tsync); + +struct tracecmd_clock_sync ; + +int tracecmd_msg_rcv_time_sync (struct tracecmd_msg_handle *msg_handle, +struct tracecmd_clock_sync *clock_sync, +long long *offset,long long *timestamp); +int tracecmd_msg_snd_time_sync (struct tracecmd_msg_handle *msg_handle, +struct tracecmd_clock_sync *clock_sync, +long long *offset,long long *timestamp);/* --- Plugin handling --- */ extern struct tep_plugin_option trace_ftrace_options[];
tracecmd/Makefile +1 -0
@@ -32,6 +32,7 @@ TRACE_CMD_OBJS += trace-list.o TRACE_CMD_OBJS += trace-output.o TRACE_CMD_OBJS += trace-usage.o TRACE_CMD_OBJS += trace-msg.o +TRACE_CMD_OBJS += trace-timesync.o ifeq ($(VSOCK_DEFINED), 1) TRACE_CMD_OBJS += trace-agent.o
tracecmd/include/trace-local.h +32 -1
@@ -26,6 +26,7 @@ extern int quiet;typedef unsigned long long u64 ;struct buffer_instance ; +struct tracecmd_clock_sync ;/* for local shared information with trace-cmd executable */
@@ -101,7 +102,7 @@ void trace_usage(int argc, char **argv);int trace_record_agent (struct tracecmd_msg_handle *msg_handle,int cpus,int *fds, -int argc,char **argv,bool use_fifos); +int argc,char **argv,bool use_fifos,bool do_tsync);struct hook_list ;
@@ -214,6 +215,12 @@ struct buffer_instance {unsigned int port;int *fds;bool use_fifos; +bool do_tsync; + +struct tracecmd_clock_sync *clock_sync; +int time_sync_count; +long long *time_sync_ts; +long long *time_sync_offsets; };extern struct buffer_instance top_instance;
@@ -235,6 +242,30 @@ void update_first_instance(struct buffer_instance *instance, int topt);void show_instance_file (struct buffer_instance *instance,const char *name);int count_cpus (void ); + +struct tracecmd_time_sync_event { +int id; +int cpu; +int pid; +unsigned long long ts; +}; + +int tracecmd_clock_get_peer (struct tracecmd_clock_sync *clock_context, +unsigned int *remote_cid,unsigned int *remote_port); +bool tracecmd_time_sync_check (void ); +void tracecmd_clock_context_free (struct buffer_instance *instance); +int tracecmd_clock_find_event (struct tracecmd_clock_sync *clock,int cpu, +struct tracecmd_time_sync_event *event); +void tracecmd_clock_synch_enable (struct tracecmd_clock_sync *clock_context); +void tracecmd_clock_synch_disable (struct tracecmd_clock_sync *clock_context); +void tracecmd_clock_synch_calc_reset (struct tracecmd_clock_sync *clock_context); +void tracecmd_clock_synch_calc_probe (struct tracecmd_clock_sync *clock_context, +long long ts_local,long long ts_remote); +int tracecmd_clock_synch_calc (struct tracecmd_clock_sync *clock_context, +long long *offset_ret,long long *time_ret); +void sync_time_with_host_v3 (struct buffer_instance *instance); +void sync_time_with_guest_v3 (struct buffer_instance *instance); +void write_tracing_on (struct buffer_instance *instance,int on);char *get_instance_dir (struct buffer_instance *instance); int write_instance_file(struct buffer_instance *instance,
tracecmd/trace-agent.c +10 -3
@@ -132,6 +132,7 @@ static void agent_handle(int sd, int nr_cpus, int page_size)char **argv =NULL ;int argc =0 ;bool use_fifos; +bool do_tsync;int *fds;int ret;
@@ -144,7 +145,8 @@ static void agent_handle(int sd, int nr_cpus, int page_size)if (!msg_handle)die ("Failed to allocate message handle" ); - ret =tracecmd_msg_recv_trace_req (msg_handle, &argc, &argv, &use_fifos); + ret =tracecmd_msg_recv_trace_req (msg_handle, &argc, &argv, + &use_fifos, &do_tsync);if (ret <0 )die ("Failed to receive trace request" );
@@ -153,13 +155,18 @@ static void agent_handle(int sd, int nr_cpus, int page_size)if (!use_fifos)make_vsocks (nr_cpus, fds, ports); +if (do_tsync) { + do_tsync =tracecmd_time_sync_check (); +if (!do_tsync) +warning ("Failed to negotiate timestamps synchronization with the host" ); + } ret =tracecmd_msg_send_trace_resp (msg_handle, nr_cpus, page_size, - ports, use_fifos); + ports, use_fifos, do_tsync);if (ret <0 )die ("Failed to send trace response" ); -trace_record_agent (msg_handle, nr_cpus, fds, argc, argv, use_fifos); +trace_record_agent (msg_handle, nr_cpus, fds, argc, argv, use_fifos, do_tsync);free (argv[0 ]);free (argv);
tracecmd/trace-msg.c +187 -22
318 lines not on this page · raw message
tracecmd/trace-record.c +78 -6
166 lines not on this page · raw message
tracecmd/trace-timesync.c new file +808 -0
808 lines not on this page · raw message
Signature · 1 line
2.20.1
Quoted 69 lines · On Thu, 25 Apr 2019 14:05:22 +0300 Tzvetomir Stoyanov <[email protected]>…
[
v11 changes:
- Rebased on top of Slavomir's v10 "Add VM kernel tracing over vsockets and FIFOs"
- Addressed Slavomir's commnents from version 10 of the patch series.v10 changes:
- Fixed broken compilation, call totimestamp_correction_calc()intimestamp_correctwas smashed.
- Replaced deprecatedtep_data_event_from_type()API withtep_find_event().
- Fixed a warning on assignment const to non const.v9 changes:
- Fixed implementation of binary search algorithm intimestamp_correct()v8 changes:
- Addedrmdir()call intracecmd_remove_instance(), to completely remove the instance. However, there is an issue with deleting the instances usingrmdir(), which is investigated.
- Few changes inread_qemu_guests_pids(),timestamp_correct(),tsync_offset_load()
tracecmd_clock_context_new()andfind_raw_events()suggested by Slavomir.v7 changes:
- Added warning messages in case time synchronization cannot be negotiated or fails.
- Few optimizations and checks inread_qemu_guests_pids(),tsync_offset_load(), andfind_raw_events(), suggested by Slavomir Kaslev.
- Reworkedtimestamp_correct()to not use static variables.
- CheckTRACECMD_OPTION_TIME_SHIFTbefore reading time sync samples from the trace.dat filev6 changes:
- Refactoredtracecmd_msg_snd_time_sync()andtracecmd_msg_rcv_time_sync()functions:
removed any time sync calculations logic as separate functions intrace-timesync.cfile
- DefinedTSYNC_PROBE,TSYNC_REQandTSYNC_RESPmessages, in order to make the time sync protocol comprehensible.
- Addressed Steven Rostedt comments.
- Addressed Slavomir Kaslev commnets.v5 changes:
- Rebased to Slavomir's v8 "Add VM kernel tracing over vsockets and FIFOs" patch series.
- Implemented an algorithm for time drift correction.
- Addressed Slavomir's commnets.
- Refactored the code: moved all time sync specific implementation intrace-timesync.c
- Isolated all hardcoded event specific stuff in a structure, so it could be easily moved to external plugins.
- Added a check for VSOCK support: do not perform vsock dependent time synchronisation in case there is no VSOCK support.v4 changes:
- Removed the implementation of PTP-like algorithm. The current logic relies on matching time stamps of kvm_exit/virtio_transport_recv_pkt events on host to virtio_transport_alloc_pkt/vp_notify events on guest.
- Rebased to Slavomir's v7 "Add VM kernel tracing over vsockets and FIFOs" patch series.
- Decreased the time synch probes from 5000 to 300.
- Addressed Steven Rostedt comments.
- Code cleanup.v3 changes:
- Removed any magic constants, used in the PTP-like algorithm, as Slavomir Kaslev suggested.
- Implemented new algorithm, based on mappingkvm_exitevents in host context tovsock_sendevents in guest context, suggested by Steven Rostedt.v2 changes:
- Addressed Steven Rostedt comments.
- Modified PTP-like timestamps sync algorithm to gain more accuracy, with the help of Yordan Karadzhov and Slavomir Kaslev.
]
Quoted 5 lines
POC implementation of algorithm for timestamps sync between guest and host machines. The algorithm relies on matching time stamps of guest and host vsock events.
The patch series depends on Slavomir's changes, introduced by the v10 patch series "Add VM kernel tracing over vsockets and FIFOs"
Hi Ceco,
I did a bit of playing to get this working too, and even tried to see events that map perfectly and found the connection not that reliable. Partly because, there could be a drift in the clocks themselves, which exact measurement may not be as accurate. And since vsocks has a lot of overhead between the sending and receiving, it creates a much bigger variance and difficultly to find the best events to compare with.
I'm thinking that we should go back to your P2P patches. Could you rebase them tomorrow and resend them?
Don't worry about making them part of the plugin work. This is still just prototype/demo for me ;-)
Thanks!
-- Steve
Quoted 31 lines
Tzvetomir Stoyanov (9):
trace-cmd: Implemented new lib API:tracecmd_local_events_system()
trace-cmd: Added support for negative time offsets in trace.dat file
trace-cmd: Fixtracecmd_read_page_record()to read more than one event
trace-cmd: Added implementation ofhtonll()andntohll()
trace-cmd: Refactored few functions intrace-record.c
trace-cmd: Find and store pids of tasks, which run virtual CPUs of
given VM
trace-cmd: Implemented new APItracecmd_add_option_v()
trace-cmd: Implemented new option in trace.dat file:
TRACECMD_OPTION_TIME_SHIFT
trace-cmd [POC]: Implemented timestamps synch algorithm, using vsock
events.include/trace-cmd/trace-cmd.h | 31 +- include/traceevent/event-parse.h | 1 + lib/trace-cmd/trace-input.c | 145 +++++- lib/trace-cmd/trace-util.c | 98 ++-- tracecmd/Makefile | 1 + tracecmd/include/trace-local.h | 43 +- tracecmd/include/trace-msg.h | 10 + tracecmd/trace-agent.c | 13 +- tracecmd/trace-msg.c | 209 +++++++- tracecmd/trace-output.c | 117 ++++- tracecmd/trace-read.c | 4 +- tracecmd/trace-record.c | 229 +++++++-- tracecmd/trace-timesync.c | 808 +++++++++++++++++++++++++++++++ 13 files changed, 1575 insertions(+), 134 deletions(-) create mode 100644 tracecmd/trace-timesync.c