Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1310979
| From | Namhyung Kim <namhyung@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 04/17] perf hists: Cleanup filtering functions |
| Date | 2016-01-16 17:10 +0100 |
| Message-ID | <qRBAn-6Ad-27@gated-at.bofh.it> (permalink) |
| References | <qRBAm-6Ad-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
The hists__filter_by_xxx functions share same logic with different
filters. Factor out the common code into the hists__filter_by_type.
The hists__filter_by_dso() code contained a check for parent, but I
think it should not be there. The PARENT filter bit was set by
symbol__parent_filter() which is related to symbol instead of dso. Also
it didn't change the filter state anyway so end result will be same.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/util/hist.c | 92 ++++++++++++++++----------------------------------
1 file changed, 29 insertions(+), 63 deletions(-)
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 9354455aec5b..0790c053f65c 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1471,28 +1471,6 @@ static bool hists__filter_entry_by_dso(struct hists *hists,
return false;
}
-void hists__filter_by_dso(struct hists *hists)
-{
- struct rb_node *nd;
-
- hists->stats.nr_non_filtered_samples = 0;
-
- hists__reset_filter_stats(hists);
- 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 (symbol_conf.exclude_other && !h->parent)
- continue;
-
- if (hists__filter_entry_by_dso(hists, h))
- continue;
-
- hists__remove_entry_filter(hists, h, HIST_FILTER__DSO);
- }
-}
-
static bool hists__filter_entry_by_thread(struct hists *hists,
struct hist_entry *he)
{
@@ -1505,25 +1483,6 @@ static bool hists__filter_entry_by_thread(struct hists *hists,
return false;
}
-void hists__filter_by_thread(struct hists *hists)
-{
- struct rb_node *nd;
-
- hists->stats.nr_non_filtered_samples = 0;
-
- hists__reset_filter_stats(hists);
- 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_thread(hists, h))
- continue;
-
- hists__remove_entry_filter(hists, h, HIST_FILTER__THREAD);
- }
-}
-
static bool hists__filter_entry_by_symbol(struct hists *hists,
struct hist_entry *he)
{
@@ -1537,25 +1496,6 @@ static bool hists__filter_entry_by_symbol(struct hists *hists,
return false;
}
-void hists__filter_by_symbol(struct hists *hists)
-{
- struct rb_node *nd;
-
- hists->stats.nr_non_filtered_samples = 0;
-
- hists__reset_filter_stats(hists);
- 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);
- }
-}
-
static bool hists__filter_entry_by_socket(struct hists *hists,
struct hist_entry *he)
{
@@ -1568,7 +1508,9 @@ static bool hists__filter_entry_by_socket(struct hists *hists,
return false;
}
-void hists__filter_by_socket(struct hists *hists)
+typedef bool (*filter_fn_t)(struct hists *hists, struct hist_entry *he);
+
+static void hists__filter_by_type(struct hists *hists, int type, filter_fn_t filter)
{
struct rb_node *nd;
@@ -1580,13 +1522,37 @@ void hists__filter_by_socket(struct hists *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_socket(hists, h))
+ if (filter(hists, h))
continue;
- hists__remove_entry_filter(hists, h, HIST_FILTER__SOCKET);
+ hists__remove_entry_filter(hists, h, type);
}
}
+void hists__filter_by_thread(struct hists *hists)
+{
+ hists__filter_by_type(hists, HIST_FILTER__THREAD,
+ hists__filter_entry_by_thread);
+}
+
+void hists__filter_by_dso(struct hists *hists)
+{
+ hists__filter_by_type(hists, HIST_FILTER__DSO,
+ hists__filter_entry_by_dso);
+}
+
+void hists__filter_by_symbol(struct hists *hists)
+{
+ hists__filter_by_type(hists, HIST_FILTER__SYMBOL,
+ hists__filter_entry_by_symbol);
+}
+
+void hists__filter_by_socket(struct hists *hists)
+{
+ hists__filter_by_type(hists, HIST_FILTER__SOCKET,
+ hists__filter_entry_by_socket);
+}
+
void events_stats__inc(struct events_stats *stats, u32 type)
{
++stats->nr_events[0];
--
2.6.4
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[RFC/PATCHSET 00/17] perf tools: Add support for hierachy view (v2) Namhyung Kim <namhyung@kernel.org> - 2016-01-16 17:10 +0100
[PATCH 16/17] perf hists: Support decaying in hierarchy mode Namhyung Kim <namhyung@kernel.org> - 2016-01-16 17:10 +0100
[PATCH 13/17] perf hists browser: Align column header in hierarchy mode Namhyung Kim <namhyung@kernel.org> - 2016-01-16 17:10 +0100
[PATCH 15/17] perf report: Add --hierarchy option Namhyung Kim <namhyung@kernel.org> - 2016-01-16 17:10 +0100
[PATCH 01/17] perf hists: Basic support of hierarchical report view Namhyung Kim <namhyung@kernel.org> - 2016-01-16 17:10 +0100
Re: [PATCH 01/17] perf hists: Basic support of hierarchical report view Jiri Olsa <jolsa@redhat.com> - 2016-01-17 17:20 +0100
Re: [PATCH 01/17] perf hists: Basic support of hierarchical report view Namhyung Kim <namhyung@kernel.org> - 2016-01-19 12:00 +0100
Re: [PATCH 01/17] perf hists: Basic support of hierarchical report view Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-19 18:00 +0100
Re: [PATCH 01/17] perf hists: Basic support of hierarchical report view Jiri Olsa <jolsa@redhat.com> - 2016-01-20 18:10 +0100
Re: [PATCH 01/17] perf hists: Basic support of hierarchical report view Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-20 18:20 +0100
Re: [PATCH 01/17] perf hists: Basic support of hierarchical report view Namhyung Kim <namhyung@kernel.org> - 2016-01-21 05:10 +0100
Re: [PATCH 01/17] perf hists: Basic support of hierarchical report view Jiri Olsa <jolsa@redhat.com> - 2016-01-21 11:50 +0100
Re: [PATCH 01/17] perf hists: Basic support of hierarchical report view Namhyung Kim <namhyung@kernel.org> - 2016-01-21 14:00 +0100
Re: [PATCH 01/17] perf hists: Basic support of hierarchical report view Jiri Olsa <jolsa@redhat.com> - 2016-01-21 14:40 +0100
Re: [PATCH 01/17] perf hists: Basic support of hierarchical report view Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-21 15:10 +0100
Re: [PATCH 01/17] perf hists: Basic support of hierarchical report view Namhyung Kim <namhyung@kernel.org> - 2016-01-22 11:50 +0100
Re: [PATCH 01/17] perf hists: Basic support of hierarchical report view Namhyung Kim <namhyung@kernel.org> - 2016-01-22 11:50 +0100
Re: [PATCH 01/17] perf hists: Basic support of hierarchical report view Jiri Olsa <jolsa@redhat.com> - 2016-01-22 12:40 +0100
Re: [PATCH 01/17] perf hists: Basic support of hierarchical report view Jiri Olsa <jolsa@redhat.com> - 2016-01-21 12:40 +0100
Re: [PATCH 01/17] perf hists: Basic support of hierarchical report view Namhyung Kim <namhyung@kernel.org> - 2016-01-21 14:10 +0100
[PATCH 08/17] perf hists browser: Fix context menu item Namhyung Kim <namhyung@kernel.org> - 2016-01-16 17:10 +0100
Re: [PATCH 08/17] perf hists browser: Fix context menu item Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-21 02:00 +0100
Re: [PATCH 08/17] perf hists browser: Fix context menu item Namhyung Kim <namhyung@kernel.org> - 2016-01-21 05:10 +0100
Re: [PATCH 08/17] perf hists browser: Fix context menu item Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-22 01:00 +0100
Re: [PATCH 08/17] perf hists browser: Fix context menu item Namhyung Kim <namhyung@kernel.org> - 2016-01-22 12:10 +0100
Dynamicly add/remove sort keys was: Re: [PATCH 08/17] perf hists browser: Fix context menu item Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-22 15:40 +0100
[PATCH 04/17] perf hists: Cleanup filtering functions Namhyung Kim <namhyung@kernel.org> - 2016-01-16 17:10 +0100
Re: [PATCH 04/17] perf hists: Cleanup filtering functions Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-19 21:40 +0100
[PATCH v2 04.1/17] perf hists: Remove parent filter check in DSO filter function Namhyung Kim <namhyung@kernel.org> - 2016-01-20 02:30 +0100
[PATCH v2 04.2/17] perf hists: Cleanup filtering functions Namhyung Kim <namhyung@kernel.org> - 2016-01-20 02:30 +0100
Re: [PATCH v2 04.2/17] perf hists: Cleanup filtering functions Jiri Olsa <jolsa@redhat.com> - 2016-01-21 13:10 +0100
Re: [PATCH v2 04.1/17] perf hists: Remove parent filter check in DSO filter function Jiri Olsa <jolsa@redhat.com> - 2016-01-21 13:10 +0100
[PATCH 02/17] perf hists: Resort hist entries with hierarchy Namhyung Kim <namhyung@kernel.org> - 2016-01-16 17:10 +0100
Re: [PATCH 02/17] perf hists: Resort hist entries with hierarchy Jiri Olsa <jolsa@redhat.com> - 2016-01-21 12:50 +0100
Re: [PATCH 02/17] perf hists: Resort hist entries with hierarchy Namhyung Kim <namhyung@kernel.org> - 2016-01-21 14:10 +0100
[PATCH 10/17] perf hists browser: Support collapsing/expanding whole entries in hierarchy Namhyung Kim <namhyung@kernel.org> - 2016-01-16 17:10 +0100
[PATCH 07/17] perf ui/stdio: Align column header for hierarchy output Namhyung Kim <namhyung@kernel.org> - 2016-01-16 17:10 +0100
Re: [PATCH 07/17] perf ui/stdio: Align column header for hierarchy output Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-20 23:50 +0100
Re: [PATCH 07/17] perf ui/stdio: Align column header for hierarchy output Namhyung Kim <namhyung@kernel.org> - 2016-01-21 05:10 +0100
[PATCH 12/17] perf hists browser: Implement hierarchy output Namhyung Kim <namhyung@kernel.org> - 2016-01-16 17:10 +0100
[PATCH 05/17] perf hists: Support filtering in hierarchy mode Namhyung Kim <namhyung@kernel.org> - 2016-01-16 17:10 +0100
[PATCH 11/17] perf hists browser: Factor out hist_browser__show_callchain() Namhyung Kim <namhyung@kernel.org> - 2016-01-16 17:10 +0100
[PATCH 06/17] perf ui/stdio: Implement hierarchy output mode Namhyung Kim <namhyung@kernel.org> - 2016-01-16 17:10 +0100
[PATCH 03/17] perf hists: Add helper functions for hierarchy mode Namhyung Kim <namhyung@kernel.org> - 2016-01-16 17:10 +0100
Re: [PATCH 03/17] perf hists: Add helper functions for hierarchy mode Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-20 23:20 +0100
Re: [PATCH 03/17] perf hists: Add helper functions for hierarchy mode Namhyung Kim <namhyung@kernel.org> - 2016-01-21 05:00 +0100
[PATCH v2 03/17] perf hists: Add helper functions for hierarchy mode Namhyung Kim <namhyung@kernel.org> - 2016-01-21 05:20 +0100
Re: [PATCH v2 03/17] perf hists: Add helper functions for hierarchy mode Namhyung Kim <namhyung@kernel.org> - 2016-01-21 14:10 +0100
[PATCH 09/17] perf hists browser: Count number of hierarchy entries Namhyung Kim <namhyung@kernel.org> - 2016-01-16 17:10 +0100
Re: [RFC/PATCHSET 00/17] perf tools: Add support for hierachy view (v2) Pekka Enberg <penberg@kernel.org> - 2016-01-17 11:30 +0100
Re: [RFC/PATCHSET 00/17] perf tools: Add support for hierachy view (v2) Namhyung Kim <namhyung@kernel.org> - 2016-01-19 11:50 +0100
Re: [RFC/PATCHSET 00/17] perf tools: Add support for hierachy view (v2) Andi Kleen <andi@firstfloor.org> - 2016-01-17 20:40 +0100
Re: [RFC/PATCHSET 00/17] perf tools: Add support for hierachy view (v2) Namhyung Kim <namhyung@kernel.org> - 2016-01-19 11:50 +0100
Re: [RFC/PATCHSET 00/17] perf tools: Add support for hierachy view (v2) Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-19 22:10 +0100
Re: [RFC/PATCHSET 00/17] perf tools: Add support for hierachy view (v2) Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-19 22:10 +0100
Re: [RFC/PATCHSET 00/17] perf tools: Add support for hierachy view (v2) Andi Kleen <andi@firstfloor.org> - 2016-01-19 23:20 +0100
Re: [RFC/PATCHSET 00/17] perf tools: Add support for hierachy view (v2) Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-19 23:30 +0100
Re: [RFC/PATCHSET 00/17] perf tools: Add support for hierachy view (v2) Namhyung Kim <namhyung@kernel.org> - 2016-01-20 02:00 +0100
Re: [RFC/PATCHSET 00/17] perf tools: Add support for hierachy view (v2) Namhyung Kim <namhyung@kernel.org> - 2016-01-20 02:40 +0100
Re: [RFC/PATCHSET 00/17] perf tools: Add support for hierachy view (v2) Andi Kleen <andi@firstfloor.org> - 2016-01-20 02:50 +0100
Re: [RFC/PATCHSET 00/17] perf tools: Add support for hierachy view (v2) Andi Kleen <andi@firstfloor.org> - 2016-01-20 03:00 +0100
Re: [RFC/PATCHSET 00/17] perf tools: Add support for hierachy view (v2) Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-20 14:40 +0100
Re: [RFC/PATCHSET 00/17] perf tools: Add support for hierachy view (v2) Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-19 21:10 +0100
Re: [RFC/PATCHSET 00/17] perf tools: Add support for hierachy view (v2) Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-19 22:00 +0100
Re: [RFC/PATCHSET 00/17] perf tools: Add support for hierachy view (v2) Namhyung Kim <namhyung@kernel.org> - 2016-01-20 01:40 +0100
Re: [RFC/PATCHSET 00/17] perf tools: Add support for hierachy view (v2) Andi Kleen <andi@firstfloor.org> - 2016-01-20 06:30 +0100
Re: [RFC/PATCHSET 00/17] perf tools: Add support for hierachy view (v2) Taeung Song <taeung.dev@gmail.com> - 2016-01-20 09:00 +0100
Re: [RFC/PATCHSET 00/17] perf tools: Add support for hierachy view (v2) Namhyung Kim <namhyung@kernel.org> - 2016-01-20 16:10 +0100
Re: [RFC/PATCHSET 00/17] perf tools: Add support for hierachy view (v2) Taeung Song <taeung.dev@gmail.com> - 2016-01-20 17:40 +0100
Re: [RFC/PATCHSET 00/17] perf tools: Add support for hierachy view (v2) Namhyung Kim <namhyung@kernel.org> - 2016-01-21 05:20 +0100
Re: [RFC/PATCHSET 00/17] perf tools: Add support for hierachy view (v2) Taeung Song <taeung.dev@gmail.com> - 2016-01-21 06:00 +0100
Re: [RFC/PATCHSET 00/17] perf tools: Add support for hierachy view (v2) Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-20 14:40 +0100
Re: [RFC/PATCHSET 00/17] perf tools: Add support for hierachy view (v2) Namhyung Kim <namhyung@kernel.org> - 2016-01-20 16:10 +0100
Re: [RFC/PATCHSET 00/17] perf tools: Add support for hierachy view (v2) Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-20 16:30 +0100
Re: [RFC/PATCHSET 00/17] perf tools: Add support for hierachy view (v2) Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-20 16:30 +0100
Re: [RFC/PATCHSET 00/17] perf tools: Add support for hierachy view (v2) Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-19 22:00 +0100
Re: [RFC/PATCHSET 00/17] perf tools: Add support for hierachy view (v2) Namhyung Kim <namhyung@kernel.org> - 2016-01-20 01:20 +0100
csiph-web