Skip to contentSkip to conversation

perf report: Don't add filtered events to histogram

RFC PATCH In review Steve Capper 2 participants 2 messages Apr 14, 2015 perf events

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 perf report: Don't add filtered events to histogram

If one filters events by a single comm in perf report via:
perf report --no-children -c program-name

perf will elide the comm column as only one comm is filtered in. This lack of distinction by comm can lead to events being merged in add_hist_entry that have different comm's, including events that have been filtered out and filtered in. Ultimately, this can lead to events disappearing from the report.

If one instead invokes perf via:
perf report --no-children -c program-name,random-made-up-name

Then the comm column remains and all the expected events are present.

This patch prevents filtered out events from being considered by hist_entry_iter__add.

Cc Peter Zijlstra <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>

---
Hi,
This patch fixes my problem, but I don't know enough perf to confidently state that this will work everywhere (hence this being marked as an RFC).

Please let me know if I've missed something and I'll be happy to re-spin/test/submit.

Cheers,

Signature · 4 lines
Steve
---
 tools/perf/builtin-report.c | 3 +++
 1 file changed, 3 insertions(+)
tools/perf/builtin-report.c +3 -0
index 2f91094..3eaf46e 100644
@@ -166,6 +166,9 @@ static int process_sample_event(struct perf_tool *tool,
 	if (al.map != NULL)
 		al.map->dso->hit = 1;
 
+	if (al.filtered)
+		return 0;
+
 	ret = hist_entry_iter__add(&iter, &al, evsel, sample, rep->max_stack,
 				   rep);
 	if (ret < 0)
Signature · 1 line
2.1.0
maintainer Acked-by Jiri Olsa on v1 1/1
#1 lore raw

Em Tue, Apr 14, 2015 at 01:05:03PM +0100, Steve Capper escreveu:

Quoted 2 lines

If one filters events by a single comm in perf report via:
perf report --no-children -c program-name

This seems right even without any explanation, wonder when was that this bug was added or what is that we are missing here...

commit 2c86c7ca760634f09dcbd76069e5102b4de6f8f1

Author: Namhyung Kim <[email protected]>
Date:   Mon Mar 17 18:18:54 2014 -0300

perf report: Merge al->filtered with hist_entry->filtered

I.e. don't drop al->filtered entries, create the hist_entries and use its ->filtered bitmap, that is kept with the same semantics for its bitmap, leaving the filtering to be done at the hist_entry level, i.e. in the UIs.

This will allow zooming in/out the filters.

Cc Andi Kleen <[email protected]>
Cc David Ahern <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
[ yanked this out of a previous patch ]
tools/perf/builtin-report.c +0 -0
index c47bf586fcba..a74059f0c45f 100644
@@ -231,7 +231,7 @@ static int process_sample_event(struct perf_tool

*tool,

                return -1;
        }

- if (al.filtered || (rep->hide_unresolved && al.sym == NULL))
+ if (rep->hide_unresolved && al.sym == NULL)

                return 0;
 
        if (rep->cpu_list && !test_bit(sample->cpu, rep->cpu_bitmap))

--------------------------------------------------------------

So, yes, what you did was what was there in the first place, but now we need to try to have the above cset in mind before proceeding...

- Arnaldo

Quoted 13 lines

+++ b/tools/perf/builtin-report.c

(quoted diff) +3 -0
@@ -166,6 +166,9 @@ static int process_sample_event(struct perf_tool *tool,
 	if (al.map != NULL)
 		al.map->dso->hit = 1;
 
+	if (al.filtered)
+		return 0;
+
 	ret = hist_entry_iter__add(&iter, &al, evsel, sample, rep->max_stack,
 				   rep);
 	if (ret < 0)
Signature · 1 line
2.1.0