Initial support for containers tracing
cover Initial support for containers tracing
Add support for trace-cmd filtering PIDs per ftrace instance. Intoduce the "--container" command, which uses ftrace PIDs filtering per instance.
Tzvetomir Stoyanov (VMware) (2):
trace-cmd: Handle filtered PIDs per ftarce instance
trace-cmd: [POC] Add command for container tracing
include/trace-cmd/trace-cmd.h | 3 + lib/trace-cmd/Makefile | 1 + lib/trace-cmd/trace-containers.c | 141 ++++++++ tracecmd/include/trace-local.h | 25 +- tracecmd/trace-record.c | 580 ++++++++++++++++++------------- 5 files changed, 502 insertions(+), 248 deletions(-) create mode 100644 lib/trace-cmd/trace-containers.c
Signature · 1 line
2.26.2
PATCH 1/2 trace-cmd: Handle filtered PIDs per ftarce instance
Ftrace supports PID filtering per instance. Currently trace-cmd does not use this functionality, all PIDs specified with "-P" option are propagated to all configured tracing instances. The patch affects these trace-cmd options:
-P, -O, -T, --proc-map
their configuration scope is limited to the specified ftrace instance only. If no instance is specified, the configuration is applied to the main instance.
--- tracecmd/include/trace-local.h | 24 +- tracecmd/trace-record.c | 535 ++++++++++++++++++--------------- 2 files changed, 317 insertions(+), 242 deletions(-)
tracecmd/include/trace-local.h +23 -1
@@ -184,6 +184,17 @@ struct pid_addr_maps {int pid; }; +struct opt_list { +struct opt_list *next; +const char *option; +}; + +struct filter_pids { +struct filter_pids *next; +int pid; +int exclude; +}; +struct buffer_instance {struct buffer_instance *next;struct tracefs_instance *tracefs;
@@ -202,6 +213,18 @@ struct buffer_instance {struct func_list *filter_funcs;struct func_list *notrace_funcs; +struct opt_list *options; +struct filter_pids *filter_pids; +char *common_pid_filter; +int nr_filter_pids; +int len_filter_pids; +bool ptrace_child; + +int have_set_event_pid; +int have_event_fork; +int have_func_fork; +int get_procmap; +const char *clock;unsigned int *client_ports;
@@ -260,7 +283,6 @@ int get_guest_vcpu_pid(unsigned int guest_cid, unsigned int guest_vcpu);/* moved from trace-cmd.h */ void tracecmd_create_top_instance (char *name);void tracecmd_remove_instances (void ); -void tracecmd_filter_pid (int pid,int exclude);int tracecmd_add_event (const char *event_str,int stack);void tracecmd_enable_events (void );void tracecmd_disable_all_tracing (int disable_tracer);
tracecmd/trace-record.c +294 -241
990 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH 2/2 trace-cmd: [POC] Add command for container tracing
In reply to Tzvetomir Stoyanov (VMware)A new command "--container <container-id>" is added to "trace-cmd record" sub command. It creates a ftrace instance and runs the tracing of container's PIDs into it. Multiple "--container" options can be specified, to trace multiple containers at the same time. The new option behaves as "-B": all trace-cmd options specified after "--container" affect only the tracing related to this container.
The patch is a POC, it introduces the infrastructure and helper functions for container tracing.
--- include/trace-cmd/trace-cmd.h | 3 + lib/trace-cmd/Makefile | 1 + lib/trace-cmd/trace-containers.c | 141 +++++++++++++++++++++++++++++++ tracecmd/include/trace-local.h | 1 + tracecmd/trace-record.c | 59 ++++++++++--- 5 files changed, 192 insertions(+), 13 deletions(-) create mode 100644 lib/trace-cmd/trace-containers.c
include/trace-cmd/trace-cmd.h +3 -0
@@ -501,4 +501,7 @@ void *tracecmd_record_page(struct tracecmd_input *handle,void *tracecmd_record_offset (struct tracecmd_input *handle,struct tep_record *record); +/* --- Containers --- */ +int tracecmd_get_container_pids (char *cont_id,int **pids,int *pids_count); +#endif /* _TRACE_CMD_H */
lib/trace-cmd/Makefile +1 -0
@@ -17,6 +17,7 @@ OBJS += trace-filter-hash.o OBJS += trace-msg.o OBJS += trace-plugin.o OBJS += trace-timesync.o +OBJS += trace-containers.o # Additional util objects OBJS += trace-blk-hack.o
lib/trace-cmd/trace-containers.c new file +141 -0
141 lines not on this page · raw message
tracecmd/include/trace-local.h +1 -0
@@ -168,6 +168,7 @@ enum buffer_instance_flags {BUFFER_FL_GUEST =1 <<2 ,BUFFER_FL_AGENT =1 <<3 ,BUFFER_FL_HAS_CLOCK =1 <<4 , + BUFFER_FL_CONTAINER = 1 << 5, }; struct func_list {
tracecmd/trace-record.c +46 -13
90 lines not on this page · raw message
Signature · 1 line
2.26.2