Re: [PATCH 08/12] perf tools: Fix side band thread draining

From: Arnaldo Carvalho de Melo
Date: Tue Apr 16 2019 - 15:33:28 EST


Em Tue, Apr 16, 2019 at 06:01:23PM +0200, Jiri Olsa escreveu:
> Current perf_evlist__poll_thread code could finish
> without draining the data. Adding the logic that
> makes sure we won't finish before the drain.
>
> Fixes: 657ee5531903 ("perf evlist: Introduce side band thread")

Thanks, applied to perf/urgent.

- Arnaldo

> Link: http://lkml.kernel.org/n/tip-41i888xyim9n5ceyr44jb468@xxxxxxxxxxxxxx
> Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
> ---
> tools/perf/util/evlist.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
> index f2bbae38278d..4b6783ff5813 100644
> --- a/tools/perf/util/evlist.c
> +++ b/tools/perf/util/evlist.c
> @@ -1868,12 +1868,12 @@ static void *perf_evlist__poll_thread(void *arg)
> {
> struct perf_evlist *evlist = arg;
> bool draining = false;
> - int i;
> + int i, done = 0;
> +
> + while (!done) {
> + bool got_data = false;
>
> - while (draining || !(evlist->thread.done)) {
> - if (draining)
> - draining = false;
> - else if (evlist->thread.done)
> + if (evlist->thread.done)
> draining = true;
>
> if (!draining)
> @@ -1894,9 +1894,13 @@ static void *perf_evlist__poll_thread(void *arg)
> pr_warning("cannot locate proper evsel for the side band event\n");
>
> perf_mmap__consume(map);
> + got_data = true;
> }
> perf_mmap__read_done(map);
> }
> +
> + if (draining && !got_data)
> + break;
> }
> return NULL;
> }
> --
> 2.17.2

--

- Arnaldo