From: tip-bot for Namhyung Kim <namhyung.kim@lge.com>
To: linux-tip-commits@vger.kernel.org
Cc: acme@redhat.com, linux-kernel@vger.kernel.org, paulus@samba.org,
hpa@zytor.com, mingo@kernel.org, a.p.zijlstra@chello.nl,
namhyung.kim@lge.com, namhyung@gmail.com, tglx@linutronix.de,
mingo@elte.hu
Subject: [tip:perf/core] perf hists: Add hists__filter_by_symbol
Date: Mon, 19 Mar 2012 13:02:24 -0700 [thread overview]
Message-ID: <tip-e94d53ebec2fb4795c18ad2e76ec633390b1e794@git.kernel.org> (raw)
In-Reply-To: <1331887855-874-1-git-send-email-namhyung.kim@lge.com>
Commit-ID: e94d53ebec2fb4795c18ad2e76ec633390b1e794
Gitweb: http://git.kernel.org/tip/e94d53ebec2fb4795c18ad2e76ec633390b1e794
Author: Namhyung Kim <namhyung.kim@lge.com>
AuthorDate: Fri, 16 Mar 2012 17:50:51 +0900
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 16 Mar 2012 16:31:09 -0300
perf hists: Add hists__filter_by_symbol
This function will be used for simple (sub-)string matching filter based
on user input.
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1331887855-874-1-git-send-email-namhyung.kim@lge.com
Signed-off-by: Namhyung Kim <namhyung.kim@lge.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/hist.c | 35 +++++++++++++++++++++++++++++++++++
tools/perf/util/hist.h | 2 ++
2 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 8380c3d..2c624ad 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -10,11 +10,14 @@ static bool hists__filter_entry_by_dso(struct hists *hists,
struct hist_entry *he);
static bool hists__filter_entry_by_thread(struct hists *hists,
struct hist_entry *he);
+static bool hists__filter_entry_by_symbol(struct hists *hists,
+ struct hist_entry *he);
enum hist_filter {
HIST_FILTER__DSO,
HIST_FILTER__THREAD,
HIST_FILTER__PARENT,
+ HIST_FILTER__SYMBOL,
};
struct callchain_param callchain_param = {
@@ -420,6 +423,7 @@ static void hists__apply_filters(struct hists *hists, struct hist_entry *he)
{
hists__filter_entry_by_dso(hists, he);
hists__filter_entry_by_thread(hists, he);
+ hists__filter_entry_by_symbol(hists, he);
}
static void __hists__collapse_resort(struct hists *hists, bool threaded)
@@ -1247,6 +1251,37 @@ void hists__filter_by_thread(struct hists *hists)
}
}
+static bool hists__filter_entry_by_symbol(struct hists *hists,
+ struct hist_entry *he)
+{
+ if (hists->symbol_filter_str != NULL &&
+ (!he->ms.sym || strstr(he->ms.sym->name,
+ hists->symbol_filter_str) == NULL)) {
+ he->filtered |= (1 << HIST_FILTER__SYMBOL);
+ return true;
+ }
+
+ return false;
+}
+
+void hists__filter_by_symbol(struct hists *hists)
+{
+ struct rb_node *nd;
+
+ hists->nr_entries = hists->stats.total_period = 0;
+ hists->stats.nr_events[PERF_RECORD_SAMPLE] = 0;
+ hists__reset_col_len(hists);
+
+ for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) {
+ struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
+
+ if (hists__filter_entry_by_symbol(hists, h))
+ continue;
+
+ hists__remove_entry_filter(hists, h, HIST_FILTER__SYMBOL);
+ }
+}
+
int hist_entry__inc_addr_samples(struct hist_entry *he, int evidx, u64 ip)
{
return symbol__inc_addr_samples(he->ms.sym, he->ms.map, evidx, ip);
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 9413f3e..10343c0 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -62,6 +62,7 @@ struct hists {
const struct thread *thread_filter;
const struct dso *dso_filter;
const char *uid_filter_str;
+ const char *symbol_filter_str;
pthread_mutex_t lock;
struct events_stats stats;
u64 event_stream;
@@ -107,6 +108,7 @@ int hist_entry__annotate(struct hist_entry *self, size_t privsize);
void hists__filter_by_dso(struct hists *hists);
void hists__filter_by_thread(struct hists *hists);
+void hists__filter_by_symbol(struct hists *hists);
u16 hists__col_len(struct hists *self, enum hist_column col);
void hists__set_col_len(struct hists *self, enum hist_column col, u16 len);
prev parent reply other threads:[~2012-03-19 20:02 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-16 8:50 [PATCH v2 1/5] perf hists: Add hists__filter_by_symbol Namhyung Kim
2012-03-16 8:50 ` [PATCH v2 2/5] perf ui browser: Introduce ui_browser__input_window Namhyung Kim
2012-03-16 19:40 ` Arnaldo Carvalho de Melo
2012-03-19 2:46 ` [PATCH] perf ui browser: Clean lines inside of the input window Namhyung Kim
2012-03-19 20:06 ` [tip:perf/core] " tip-bot for Namhyung Kim
2012-03-19 20:03 ` [tip:perf/core] perf ui browser: Introduce ui_browser__input_window tip-bot for Namhyung Kim
2012-03-16 8:50 ` [PATCH v2 3/5] perf ui browser: Add 's' key to filter by symbol name Namhyung Kim
2012-03-19 20:03 ` [tip:perf/core] " tip-bot for Namhyung Kim
2012-03-16 8:50 ` [PATCH v2 4/5] perf report: Add --symbol-filter option Namhyung Kim
2012-03-16 19:42 ` Arnaldo Carvalho de Melo
2012-03-19 2:53 ` [PATCH] perf report: Document " Namhyung Kim
2012-03-19 20:07 ` [tip:perf/core] " tip-bot for Namhyung Kim
2012-03-19 20:04 ` [tip:perf/core] perf report: Add " tip-bot for Namhyung Kim
2012-03-16 8:50 ` [PATCH v2 5/5] perf report: Treat an argument as a symbol filter Namhyung Kim
2012-03-19 20:05 ` [tip:perf/core] " tip-bot for Namhyung Kim
2012-03-19 20:02 ` tip-bot for Namhyung Kim [this message]
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=tip-e94d53ebec2fb4795c18ad2e76ec633390b1e794@git.kernel.org \
--to=namhyung.kim@lge.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@kernel.org \
--cc=namhyung@gmail.com \
--cc=paulus@samba.org \
--cc=tglx@linutronix.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox