From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, David Ahern <dsahern@gmail.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
Stephane Eranian <eranian@google.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 25/25] perf tools: Add pid/tid filtering to report and script commands
Date: Tue, 24 Mar 2015 13:19:40 -0300 [thread overview]
Message-ID: <1427213980-9015-26-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1427213980-9015-1-git-send-email-acme@kernel.org>
From: David Ahern <dsahern@gmail.com>
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: David 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: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/Documentation/perf-report.txt | 5 +++++
tools/perf/Documentation/perf-script.txt | 6 ++++++
tools/perf/builtin-report.c | 4 ++++
tools/perf/builtin-script.c | 4 ++++
tools/perf/util/symbol.c | 31 ++++++++++++++++++++++++++++++-
tools/perf/util/symbol.h | 7 +++++++
tools/perf/util/thread.h | 11 +++++++++++
7 files changed, 67 insertions(+), 1 deletion(-)
diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index dd7cccdde498..4879cf638824 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -40,6 +40,11 @@ OPTIONS
Only consider symbols in these comms. CSV that understands
file://filename entries. This option will affect the percentage of
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::
--dsos=::
Only consider symbols in these dsos. CSV that understands
diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt
index a21eec05bc42..79445750fcb3 100644
--- a/tools/perf/Documentation/perf-script.txt
+++ b/tools/perf/Documentation/perf-script.txt
@@ -193,6 +193,12 @@ OPTIONS
Only display events for these comms. CSV that understands
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::
--show-info::
Display extended information about the perf.data file. This adds
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 81c2f3b97c50..b5b2ad4ca9c4 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -669,6 +669,10 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
"only consider symbols in these dsos"),
OPT_STRING('c', "comms", &symbol_conf.comm_list_str, "comm[,comm...]",
"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...]",
"only consider these symbols"),
OPT_STRING(0, "symbol-filter", &report.symbol_filter_str, "filter",
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index f2a348b57b8f..662366ceb572 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -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', "comms", &symbol_conf.comm_list_str, "comm[,comm...]",
"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,
"display extended information from perf.data file"),
OPT_BOOLEAN('\0', "show-kernel-path", &symbol_conf.show_kernel_path,
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index a69066865a55..fddeb9073039 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -15,6 +15,7 @@
#include "machine.h"
#include "symbol.h"
#include "strlist.h"
+#include "intlist.h"
#include "header.h"
#include <elf.h>
@@ -1859,6 +1860,20 @@ int setup_list(struct strlist **list, const char *list_str,
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)
{
bool value = false;
@@ -1909,9 +1924,17 @@ int symbol__init(struct perf_session_env *env)
symbol_conf.comm_list_str, "comm") < 0)
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,
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 ""
@@ -1930,6 +1953,10 @@ int symbol__init(struct perf_session_env *env)
symbol_conf.initialized = true;
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:
strlist__delete(symbol_conf.comm_list);
out_free_dso_list:
@@ -1944,6 +1971,8 @@ void symbol__exit(void)
strlist__delete(symbol_conf.sym_list);
strlist__delete(symbol_conf.dso_list);
strlist__delete(symbol_conf.comm_list);
+ intlist__delete(symbol_conf.tid_list);
+ intlist__delete(symbol_conf.pid_list);
vmlinux_path__exit();
symbol_conf.sym_list = symbol_conf.dso_list = symbol_conf.comm_list = NULL;
symbol_conf.initialized = false;
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index efdaaa544041..09561500164a 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -78,6 +78,7 @@ static inline size_t symbol__size(const struct symbol *sym)
}
struct strlist;
+struct intlist;
struct symbol_conf {
unsigned short priv_size;
@@ -115,6 +116,8 @@ struct symbol_conf {
const char *guestmount;
const char *dso_list_str,
*comm_list_str,
+ *pid_list_str,
+ *tid_list_str,
*sym_list_str,
*col_width_list_str;
struct strlist *dso_list,
@@ -124,6 +127,8 @@ struct symbol_conf {
*dso_to_list,
*sym_from_list,
*sym_to_list;
+ struct intlist *pid_list,
+ *tid_list;
const char *symfs;
};
@@ -295,5 +300,7 @@ int compare_proc_modules(const char *from, const char *to);
int setup_list(struct strlist **list, const char *list_str,
const char *list_name);
+int setup_intlist(struct intlist **list, const char *list_str,
+ const char *list_name);
#endif /* __PERF_SYMBOL */
diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h
index 783b6688d2f7..9b8a54dc34a8 100644
--- a/tools/perf/util/thread.h
+++ b/tools/perf/util/thread.h
@@ -7,6 +7,7 @@
#include <sys/types.h>
#include "symbol.h"
#include <strlist.h>
+#include <intlist.h>
struct thread_stack;
@@ -100,6 +101,16 @@ static inline bool thread__is_filtered(struct thread *thread)
return true;
}
+ if (symbol_conf.pid_list &&
+ !intlist__has_entry(symbol_conf.pid_list, thread->pid_)) {
+ return true;
+ }
+
+ if (symbol_conf.tid_list &&
+ !intlist__has_entry(symbol_conf.tid_list, thread->tid)) {
+ return true;
+ }
+
return false;
}
--
1.9.3
next prev parent reply other threads:[~2015-03-24 16:21 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-24 16:19 [GIT PULL 00/25] perf/core improvements and fixes Arnaldo Carvalho de Melo
2015-03-24 16:19 ` [PATCH 01/25] perf tools: Use kmod_path__parse in map_groups__set_modules_path_dir Arnaldo Carvalho de Melo
2015-03-24 16:19 ` [PATCH 02/25] perf tools: Use kmod_path__parse in decompress_kmodule Arnaldo Carvalho de Melo
2015-03-24 16:19 ` [PATCH 03/25] perf tools: Use kmod_path__parse in is_kernel_module Arnaldo Carvalho de Melo
2015-03-24 16:19 ` [PATCH 04/25] perf tools: Remove compressed argument from is_kernel_module Arnaldo Carvalho de Melo
2015-03-24 16:19 ` [PATCH 05/25] perf tools: Remove is_kmodule_extension function Arnaldo Carvalho de Melo
2015-03-24 16:19 ` [PATCH 06/25] perf tools: Try to lookup kernel module map before creating one Arnaldo Carvalho de Melo
2015-03-24 16:19 ` [PATCH 07/25] perf annotate: Allow annotation for decompressed kernel modules Arnaldo Carvalho de Melo
2015-03-24 16:19 ` [PATCH 08/25] perf tools: Remove (null) value of "Sort order" for perf mem report Arnaldo Carvalho de Melo
2015-03-24 16:19 ` [PATCH 09/25] perf probe: Fix to get ummapped symbol address on kernel Arnaldo Carvalho de Melo
2015-03-24 16:19 ` [PATCH 10/25] tools lib traceevent: Factor out allocating and processing args Arnaldo Carvalho de Melo
2015-03-24 16:19 ` [PATCH 11/25] perf kmem: Print big numbers using thousands' group Arnaldo Carvalho de Melo
2015-03-24 16:19 ` [PATCH 13/25] perf target: Simplify handling of strerror_r return Arnaldo Carvalho de Melo
2015-03-24 16:19 ` [PATCH 14/25] perf symbols: Save DSO loading errno to better report errors Arnaldo Carvalho de Melo
2015-03-27 10:32 ` Borislav Petkov
2015-03-27 14:37 ` Arnaldo Carvalho de Melo
2015-03-24 16:19 ` [PATCH 15/25] tools lib traceevent: Handle NULL comm name Arnaldo Carvalho de Melo
2015-03-24 16:19 ` [PATCH 16/25] tools lib traceevent: Copy trace_clock and free it Arnaldo Carvalho de Melo
2015-03-24 16:19 ` [PATCH 17/25] tools lib traceevent: Handle %z in bprint format Arnaldo Carvalho de Melo
2015-03-24 16:19 ` [PATCH 18/25] tools lib traceevent: Add pevent_data_pid_from_comm() Arnaldo Carvalho de Melo
2015-03-24 16:19 ` [PATCH 19/25] tools lib traceevent: Make plugin options either string or boolean Arnaldo Carvalho de Melo
2015-03-24 16:19 ` [PATCH 21/25] tools lib traceevent: Add way to find sub buffer boundary Arnaldo Carvalho de Melo
2015-03-24 16:19 ` [PATCH 22/25] tools lib traceevent: Free filter tokens in process_filter() Arnaldo Carvalho de Melo
2015-03-24 16:19 ` [PATCH 23/25] tools lib traceevent: Add support for __print_array() Arnaldo Carvalho de Melo
2015-03-24 16:19 ` [PATCH 24/25] perf diff: Add kallsyms option Arnaldo Carvalho de Melo
2015-03-24 16:19 ` Arnaldo Carvalho de Melo [this message]
2015-03-24 16:26 ` [GIT PULL 00/25] perf/core improvements and fixes Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1427213980-9015-26-git-send-email-acme@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=dsahern@gmail.com \
--cc=eranian@google.com \
--cc=fweisbec@gmail.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.