public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf trace: Fix events draining
@ 2019-04-18 14:04 Jiri Olsa
  0 siblings, 0 replies; only message in thread
From: Jiri Olsa @ 2019-04-18 14:04 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, Alexander Shishkin,
	Peter Zijlstra

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@kernel.org>
---
 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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2019-04-18 14:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-18 14:04 [PATCH] perf trace: Fix events draining Jiri Olsa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox