Skip to contentSkip to conversation

trace-cmd: Handle filtered PIDs per ftarce instance

PATCH New Tzvetomir Stoyanov (VMware) 1 participant 2 messages May 5, 2020

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 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.

---
v3: Check if event / function fork is supported by the kernel using the top
frtace instance, as the other instances are not yet created when the arguments are parsed.

 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
index 0f58c772..4c6a63d0 100644
@@ -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
#1 lore raw

PATCH v3 1/1 trace-cmd: List ftrace instances at the end of trace-cmd stat

By default, "trace-cmd stat" command prints status of the main ftrace instance. At top of the output there is a listing of all configured instances abd the user could be confused which status is displayed. Moved this list at the end of the command output.

---
v3: Removed the "main" when top instance is displayed and move instance
listing at the end of command's output.

 tracecmd/trace-stat.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tracecmd/trace-stat.c +3 -2
index c5057978..bd0e647a 100644
@@ -920,8 +920,7 @@ static void stat_instance(struct buffer_instance *instance)
 			printf("---------------\n");
 		printf("Instance: %s\n",
 			tracefs_instance_get_name(instance->tracefs));
-	} else
-		report_instances();
+	}
 
 	report_plugin(instance);
 	report_events(instance);
@@ -937,6 +936,8 @@ static void stat_instance(struct buffer_instance *instance)
 	report_uprobes(instance);
 	report_traceon(instance);
 	report_errorlog(instance);
+	if (instance == &top_instance)
+		report_instances();
 }
 
 void trace_stat (int argc, char **argv)
Signature · 1 line
2.26.2