Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e03eaa40 authored by David Ahern's avatar David Ahern Committed by Arnaldo Carvalho de Melo
Browse files

perf tools: Add pid/tid filtering to report and script commands



The 'record' and 'top' tools already allow a user to specify a CSV of
pids and/or tids of tasks to collect data.

Add those options to the 'report' and 'script' analysis commands to only
consider samples related to the given pids/tids.

This is also inline with the existing comm option.

Signed-off-by: default avatarDavid Ahern <dsahern@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1427212361-7066-1-git-send-email-dsahern@gmail.com


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 6b1f3423
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -40,6 +40,11 @@ OPTIONS
	Only consider symbols in these comms. CSV that understands
	Only consider symbols in these comms. CSV that understands
	file://filename entries.  This option will affect the percentage of
	file://filename entries.  This option will affect the percentage of
	the overhead column.  See --percentage for more info.
	the overhead column.  See --percentage for more info.
--pid=::
        Only show events for given process ID (comma separated list).

--tid=::
        Only show events for given thread ID (comma separated list).
-d::
-d::
--dsos=::
--dsos=::
	Only consider symbols in these dsos. CSV that understands
	Only consider symbols in these dsos. CSV that understands
+6 −0
Original line number Original line Diff line number Diff line
@@ -193,6 +193,12 @@ OPTIONS
	Only display events for these comms. CSV that understands
	Only display events for these comms. CSV that understands
	file://filename entries.
	file://filename entries.


--pid=::
	Only show events for given process ID (comma separated list).

--tid=::
	Only show events for given thread ID (comma separated list).

-I::
-I::
--show-info::
--show-info::
	Display extended information about the perf.data file. This adds
	Display extended information about the perf.data file. This adds
+4 −0
Original line number Original line Diff line number Diff line
@@ -669,6 +669,10 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
		   "only consider symbols in these dsos"),
		   "only consider symbols in these dsos"),
	OPT_STRING('c', "comms", &symbol_conf.comm_list_str, "comm[,comm...]",
	OPT_STRING('c', "comms", &symbol_conf.comm_list_str, "comm[,comm...]",
		   "only consider symbols in these comms"),
		   "only consider symbols in these comms"),
	OPT_STRING(0, "pid", &symbol_conf.pid_list_str, "pid[,pid...]",
		   "only consider symbols in these pids"),
	OPT_STRING(0, "tid", &symbol_conf.tid_list_str, "tid[,tid...]",
		   "only consider symbols in these tids"),
	OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]",
	OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]",
		   "only consider these symbols"),
		   "only consider these symbols"),
	OPT_STRING(0, "symbol-filter", &report.symbol_filter_str, "filter",
	OPT_STRING(0, "symbol-filter", &report.symbol_filter_str, "filter",
+4 −0
Original line number Original line Diff line number Diff line
@@ -1562,6 +1562,10 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
	OPT_STRING('C', "cpu", &cpu_list, "cpu", "list of cpus to profile"),
	OPT_STRING('C', "cpu", &cpu_list, "cpu", "list of cpus to profile"),
	OPT_STRING('c', "comms", &symbol_conf.comm_list_str, "comm[,comm...]",
	OPT_STRING('c', "comms", &symbol_conf.comm_list_str, "comm[,comm...]",
		   "only display events for these comms"),
		   "only display events for these comms"),
	OPT_STRING(0, "pid", &symbol_conf.pid_list_str, "pid[,pid...]",
		   "only consider symbols in these pids"),
	OPT_STRING(0, "tid", &symbol_conf.tid_list_str, "tid[,tid...]",
		   "only consider symbols in these tids"),
	OPT_BOOLEAN('I', "show-info", &show_full_info,
	OPT_BOOLEAN('I', "show-info", &show_full_info,
		    "display extended information from perf.data file"),
		    "display extended information from perf.data file"),
	OPT_BOOLEAN('\0', "show-kernel-path", &symbol_conf.show_kernel_path,
	OPT_BOOLEAN('\0', "show-kernel-path", &symbol_conf.show_kernel_path,
+30 −1
Original line number Original line Diff line number Diff line
@@ -15,6 +15,7 @@
#include "machine.h"
#include "machine.h"
#include "symbol.h"
#include "symbol.h"
#include "strlist.h"
#include "strlist.h"
#include "intlist.h"
#include "header.h"
#include "header.h"


#include <elf.h>
#include <elf.h>
@@ -1859,6 +1860,20 @@ int setup_list(struct strlist **list, const char *list_str,
	return 0;
	return 0;
}
}


int setup_intlist(struct intlist **list, const char *list_str,
		  const char *list_name)
{
	if (list_str == NULL)
		return 0;

	*list = intlist__new(list_str);
	if (!*list) {
		pr_err("problems parsing %s list\n", list_name);
		return -1;
	}
	return 0;
}

static bool symbol__read_kptr_restrict(void)
static bool symbol__read_kptr_restrict(void)
{
{
	bool value = false;
	bool value = false;
@@ -1909,9 +1924,17 @@ int symbol__init(struct perf_session_env *env)
		       symbol_conf.comm_list_str, "comm") < 0)
		       symbol_conf.comm_list_str, "comm") < 0)
		goto out_free_dso_list;
		goto out_free_dso_list;


	if (setup_intlist(&symbol_conf.pid_list,
		       symbol_conf.pid_list_str, "pid") < 0)
		goto out_free_comm_list;

	if (setup_intlist(&symbol_conf.tid_list,
		       symbol_conf.tid_list_str, "tid") < 0)
		goto out_free_pid_list;

	if (setup_list(&symbol_conf.sym_list,
	if (setup_list(&symbol_conf.sym_list,
		       symbol_conf.sym_list_str, "symbol") < 0)
		       symbol_conf.sym_list_str, "symbol") < 0)
		goto out_free_comm_list;
		goto out_free_tid_list;


	/*
	/*
	 * A path to symbols of "/" is identical to ""
	 * A path to symbols of "/" is identical to ""
@@ -1930,6 +1953,10 @@ int symbol__init(struct perf_session_env *env)
	symbol_conf.initialized = true;
	symbol_conf.initialized = true;
	return 0;
	return 0;


out_free_tid_list:
	intlist__delete(symbol_conf.tid_list);
out_free_pid_list:
	intlist__delete(symbol_conf.pid_list);
out_free_comm_list:
out_free_comm_list:
	strlist__delete(symbol_conf.comm_list);
	strlist__delete(symbol_conf.comm_list);
out_free_dso_list:
out_free_dso_list:
@@ -1944,6 +1971,8 @@ void symbol__exit(void)
	strlist__delete(symbol_conf.sym_list);
	strlist__delete(symbol_conf.sym_list);
	strlist__delete(symbol_conf.dso_list);
	strlist__delete(symbol_conf.dso_list);
	strlist__delete(symbol_conf.comm_list);
	strlist__delete(symbol_conf.comm_list);
	intlist__delete(symbol_conf.tid_list);
	intlist__delete(symbol_conf.pid_list);
	vmlinux_path__exit();
	vmlinux_path__exit();
	symbol_conf.sym_list = symbol_conf.dso_list = symbol_conf.comm_list = NULL;
	symbol_conf.sym_list = symbol_conf.dso_list = symbol_conf.comm_list = NULL;
	symbol_conf.initialized = false;
	symbol_conf.initialized = false;
Loading