[PATCH] perf trace: Fix events draining
From: Jiri Olsa
Date: Thu Apr 18 2019 - 10:04:47 EST
The event handler has currently events->disable check,
that prevents processing in case we disable the event.
It was used to bypass event display when we reach the
configured maximum via --max-events or 'nr' term. But
it collides with draining, which disables events and
processes whatever left in the buffer.
# cat ex.c
int main(void)
{
return 0;
}
# perf probe -x ./ex main
Added new event:
probe_ex:main (on main in /home/jolsa/kernel/linux-perf/tools/perf/ex)
You can now use it in all perf tools, such as:
perf record -e probe_ex:main -aR sleep 1
Before:
# perf trace -e probe_ex:main ./ex
#
After:
# perf trace -e probe_ex:main ./ex
0.000 ex/16341 probe_ex:main:(401106)
#
Checking on nr_events_printed value instead.
Fixes: a9c5e6c1e9bf ("perf trace: Introduce per-event maximum number of events property")
Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
---
tools/perf/builtin-trace.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index f5b3a1e9c1dd..729d3b82558b 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -2251,7 +2251,7 @@ static int trace__event_handler(struct trace *trace, struct perf_evsel *evsel,
* from the ring buffer that we should discard, since the max events
* have already been considered/printed.
*/
- if (evsel->disabled)
+ if (evsel->nr_events_printed == evsel->max_events)
return 0;
thread = machine__findnew_thread(trace->host, sample->pid, sample->tid);
--
2.20.1