Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1353123 > unrolled thread
| Started by | Namhyung Kim <namhyung@kernel.org> |
|---|---|
| First post | 2016-03-08 16:10 +0100 |
| Last post | 2016-03-09 13:50 +0100 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 3/6] perf tools: Fix command line filters in hierarchy mode Namhyung Kim <namhyung@kernel.org> - 2016-03-08 16:10 +0100
Re: [PATCH 3/6] perf tools: Fix command line filters in hierarchy mode Jiri Olsa <jolsa@redhat.com> - 2016-03-09 10:20 +0100
Re: [PATCH 3/6] perf tools: Fix command line filters in hierarchy mode Namhyung Kim <namhyung@kernel.org> - 2016-03-09 13:50 +0100
| From | Namhyung Kim <namhyung@kernel.org> |
|---|---|
| Date | 2016-03-08 16:10 +0100 |
| Subject | [PATCH 3/6] perf tools: Fix command line filters in hierarchy mode |
| Message-ID | <rarqO-2vx-11@gated-at.bofh.it> |
When a command-line filter was applied in hierarchy mode, output was
broken especially when filtering on lower level. The higher level
entries didn't show up so it's hard to see the result.
Also it needs to handle multi sort keys in a single level of hierarchy.
Before:
$ perf report --hierarchy -s 'cpu,{dso,comm}' --comms swapper --stdio
...
# Overhead CPU / Shared Object+Command
# ........... ...........................
#
13.79% [kernel.vmlinux] swapper
31.71% 000
13.80% [kernel.vmlinux] swapper
0.43% [e1000e] swapper
11.89% [kernel.vmlinux] swapper
9.18% [kernel.vmlinux] swapper
After:
# Overhead CPU / Shared Object+Command
# ........... ...............................
#
33.09% 003
13.79% [kernel.vmlinux] swapper
31.71% 000
13.80% [kernel.vmlinux] swapper
0.43% [e1000e] swapper
21.90% 002
11.89% [kernel.vmlinux] swapper
13.30% 001
9.18% [kernel.vmlinux] swapper
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/util/hist.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 80 insertions(+), 3 deletions(-)
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 29da9e0d8db9..7c5eb11cabb6 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1087,10 +1087,86 @@ int hist_entry__snprintf_alignment(struct hist_entry *he, struct perf_hpp *hpp,
*/
static void hists__apply_filters(struct hists *hists, struct hist_entry *he);
+static void hists__remove_entry_filter(struct hists *hists, struct hist_entry *he,
+ enum hist_filter type);
+
+typedef bool (*fmt_chk_fn)(struct perf_hpp_fmt *fmt);
+
+static bool check_thread_entry(struct perf_hpp_fmt *fmt)
+{
+ return perf_hpp__is_thread_entry(fmt) || perf_hpp__is_comm_entry(fmt);
+}
+
+static void hist_entry__check_and_remove_filter(struct hist_entry *he,
+ enum hist_filter type,
+ fmt_chk_fn check)
+{
+ struct perf_hpp_fmt *fmt;
+ bool type_match = false;
+ struct hist_entry *parent = he->parent_he;
+
+ switch (type) {
+ case HIST_FILTER__THREAD:
+ if (symbol_conf.comm_list == NULL &&
+ symbol_conf.pid_list == NULL &&
+ symbol_conf.tid_list == NULL)
+ return;
+ break;
+ case HIST_FILTER__DSO:
+ if (symbol_conf.dso_list == NULL)
+ return;
+ break;
+ case HIST_FILTER__SYMBOL:
+ if (symbol_conf.sym_list == NULL)
+ return;
+ break;
+ case HIST_FILTER__PARENT:
+ case HIST_FILTER__GUEST:
+ case HIST_FILTER__HOST:
+ case HIST_FILTER__SOCKET:
+ default:
+ return;
+ }
+
+ /* if it's filtered by own fmt, it has to have filter bits */
+ perf_hpp_list__for_each_format(he->hpp_list, fmt) {
+ if (check(fmt)) {
+ type_match = true;
+ break;
+ }
+ }
+
+ if (type_match) {
+ if (!(he->filtered & (1 << type))) {
+ while (parent) {
+ parent->filtered &= ~(1 << type);
+ parent = parent->parent_he;
+ }
+ }
+ } else {
+ if (parent == NULL)
+ he->filtered |= (1 << type);
+ else
+ he->filtered |= (parent->filtered & (1 << type));
+ }
+}
+
+static void hist_entry__apply_hierarchy_filters(struct hist_entry *he)
+{
+ hist_entry__check_and_remove_filter(he, HIST_FILTER__THREAD,
+ check_thread_entry);
+
+ hist_entry__check_and_remove_filter(he, HIST_FILTER__DSO,
+ perf_hpp__is_dso_entry);
+
+ hist_entry__check_and_remove_filter(he, HIST_FILTER__SYMBOL,
+ perf_hpp__is_sym_entry);
+}
static struct hist_entry *hierarchy_insert_entry(struct hists *hists,
struct rb_root *root,
struct hist_entry *he,
+ struct hist_entry *parent_he,
struct perf_hpp_list *hpp_list)
{
struct rb_node **p = &root->rb_node;
@@ -1125,11 +1201,13 @@ static struct hist_entry *hierarchy_insert_entry(struct hists *hists,
if (new == NULL)
return NULL;
- hists__apply_filters(hists, new);
hists->nr_entries++;
/* save related format list for output */
new->hpp_list = hpp_list;
+ new->parent_he = parent_he;
+
+ hist_entry__apply_hierarchy_filters(new);
/* some fields are now passed to 'new' */
perf_hpp_list__for_each_sort_list(hpp_list, fmt) {
@@ -1170,14 +1248,13 @@ static int hists__hierarchy_insert_entry(struct hists *hists,
continue;
/* insert copy of 'he' for each fmt into the hierarchy */
- new_he = hierarchy_insert_entry(hists, root, he, &node->hpp);
+ new_he = hierarchy_insert_entry(hists, root, he, parent, &node->hpp);
if (new_he == NULL) {
ret = -1;
break;
}
root = &new_he->hroot_in;
- new_he->parent_he = parent;
new_he->depth = depth++;
parent = new_he;
}
--
2.7.2
[toc] | [next] | [standalone]
| From | Jiri Olsa <jolsa@redhat.com> |
|---|---|
| Date | 2016-03-09 10:20 +0100 |
| Subject | Re: [PATCH 3/6] perf tools: Fix command line filters in hierarchy mode |
| Message-ID | <raIrE-5M2-1@gated-at.bofh.it> |
| In reply to | #1353123 |
On Wed, Mar 09, 2016 at 12:06:40AM +0900, Namhyung Kim wrote:
> When a command-line filter was applied in hierarchy mode, output was
> broken especially when filtering on lower level. The higher level
> entries didn't show up so it's hard to see the result.
>
> Also it needs to handle multi sort keys in a single level of hierarchy.
>
> Before:
>
> $ perf report --hierarchy -s 'cpu,{dso,comm}' --comms swapper --stdio
> ...
> # Overhead CPU / Shared Object+Command
> # ........... ...........................
> #
> 13.79% [kernel.vmlinux] swapper
> 31.71% 000
> 13.80% [kernel.vmlinux] swapper
> 0.43% [e1000e] swapper
> 11.89% [kernel.vmlinux] swapper
> 9.18% [kernel.vmlinux] swapper
>
> After:
>
> # Overhead CPU / Shared Object+Command
> # ........... ...............................
> #
> 33.09% 003
> 13.79% [kernel.vmlinux] swapper
> 31.71% 000
> 13.80% [kernel.vmlinux] swapper
> 0.43% [e1000e] swapper
> 21.90% 002
> 11.89% [kernel.vmlinux] swapper
> 13.30% 001
> 9.18% [kernel.vmlinux] swapper
I'm getting funny numbers when using 'F' toggle in tui mode
[jolsa@krava perf]$ ./perf report --hierarchy -s 'cpu,{dso,comm}' --comms swapper
Samples: 254 of event 'cycles:pp', Event count (approx.): 132263887
Overhead CPU / Shared Object+Command ◆
+ 69.85% 001 ▒
+ 44.28% 000 ▒
+ 41.62% 002 ▒
+ 36.80% 003
[jolsa@krava perf]$ sudo ./perf top --hierarchy -s 'cpu,{dso,comm}' --comms swapper
Overhead CPU / Shared O+Command
+ 320.64% 000
+ 179.91% 002
+ 137.05% 003
+ 88.37% 001
thanks,
jirka
[toc] | [prev] | [next] | [standalone]
| From | Namhyung Kim <namhyung@kernel.org> |
|---|---|
| Date | 2016-03-09 13:50 +0100 |
| Subject | Re: [PATCH 3/6] perf tools: Fix command line filters in hierarchy mode |
| Message-ID | <raLIR-7XZ-3@gated-at.bofh.it> |
| In reply to | #1353911 |
Hi Jiri,
On Wed, Mar 09, 2016 at 10:13:56AM +0100, Jiri Olsa wrote:
> On Wed, Mar 09, 2016 at 12:06:40AM +0900, Namhyung Kim wrote:
> > When a command-line filter was applied in hierarchy mode, output was
> > broken especially when filtering on lower level. The higher level
> > entries didn't show up so it's hard to see the result.
> >
> > Also it needs to handle multi sort keys in a single level of hierarchy.
> >
> > Before:
> >
> > $ perf report --hierarchy -s 'cpu,{dso,comm}' --comms swapper --stdio
> > ...
> > # Overhead CPU / Shared Object+Command
> > # ........... ...........................
> > #
> > 13.79% [kernel.vmlinux] swapper
> > 31.71% 000
> > 13.80% [kernel.vmlinux] swapper
> > 0.43% [e1000e] swapper
> > 11.89% [kernel.vmlinux] swapper
> > 9.18% [kernel.vmlinux] swapper
> >
> > After:
> >
> > # Overhead CPU / Shared Object+Command
> > # ........... ...............................
> > #
> > 33.09% 003
> > 13.79% [kernel.vmlinux] swapper
> > 31.71% 000
> > 13.80% [kernel.vmlinux] swapper
> > 0.43% [e1000e] swapper
> > 21.90% 002
> > 11.89% [kernel.vmlinux] swapper
> > 13.30% 001
> > 9.18% [kernel.vmlinux] swapper
>
> I'm getting funny numbers when using 'F' toggle in tui mode
>
> [jolsa@krava perf]$ ./perf report --hierarchy -s 'cpu,{dso,comm}' --comms swapper
>
> Samples: 254 of event 'cycles:pp', Event count (approx.): 132263887
> Overhead CPU / Shared Object+Command ◆
> + 69.85% 001 ▒
> + 44.28% 000 ▒
> + 41.62% 002 ▒
> + 36.80% 003
>
>
> [jolsa@krava perf]$ sudo ./perf top --hierarchy -s 'cpu,{dso,comm}' --comms swapper
>
> Overhead CPU / Shared O+Command
> + 320.64% 000
> + 179.91% 002
> + 137.05% 003
> + 88.37% 001
Hmm.. I think it's because that the total period is a sum of periods
of leaf nodes. But if a filter is applied, sum of periods of upper
level entries can be different than sum of the lower level entries.
So it should use top-level entries periods instead IMHO.
I will send a fix.
Thanks,
Namhyung
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web