public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Mark Rutland <mark.rutland@arm.com>
Cc: linux-kernel@vger.kernel.org,
	Adrian Hunter <adrian.hunter@intel.com>,
	Ingo Molnar <mingo@redhat.com>, Jiri Olsa <jolsa@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH] perf tools: session: avoid infinite loop
Date: Wed, 16 Sep 2015 17:54:54 -0300	[thread overview]
Message-ID: <20150916205454.GI11551@kernel.org> (raw)
In-Reply-To: <1442423929-12253-1-git-send-email-mark.rutland@arm.com>

Em Wed, Sep 16, 2015 at 06:18:49PM +0100, Mark Rutland escreveu:
> This has been observed to result in an exit-time hang when counting
> rare/unschedulable events with perf record, and can be triggered
> artificially with the script below:
> 
> ----
> #!/bin/sh
> printf "REPRO: launching perf\n";
> ./perf record -e software/config=9/ sleep 1 &
> PERF_PID=$!;
> sleep 0.002;
> kill -2 $PERF_PID;
> printf "REPRO: waiting for perf (%d) to exit...\n" "$PERF_PID";
> wait $PERF_PID;
> printf "REPRO: perf exited\n";
> ----

So, I run it here, without this patch, and get:

  [root@zoo ~]# time ./repro.sh 
  REPRO: launching perf
  REPRO: waiting for perf (766) to exit...
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.015 MB perf.data ]
  REPRO: perf exited

  real	0m1.060s
  user	0m0.018s
  sys	0m0.037s
  [root@zoo ~]# perf report --stdio
  Error:
  The perf.data file has no samples!
  # To display the perf.data header info, please use
  # --header/--header-only options.
  #
  [root@zoo ~]# perf evlist -v
  software/config=9/: type: 1, size: 112, config: 0x9, { sample_period,
  sample_freq }: 4000, sample_type: IP|TID|TIME|PERIOD, disabled: 1,
  inherit: 1, mmap: 1, comm: 1, freq: 1, enable_on_exec: 1, task: 1,
  sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
  [root@zoo ~]# 

What am I doing wrong? Trying to reproduce this before even looking at
the patch :-)

- Arnaldo
 
> To avoid this, have __perf_session__process_events bail out early when
> the file has no data (i.e. it has no events).
> 
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Cc: Adrian Hunter <adrian.hunter@intel.com>
> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Jiri Olsa <jolsa@redhat.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> ---
>  tools/perf/util/session.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
> index 8a4537e..fc3f7c9 100644
> --- a/tools/perf/util/session.c
> +++ b/tools/perf/util/session.c
> @@ -1580,7 +1580,10 @@ static int __perf_session__process_events(struct perf_session *session,
>  	file_offset = page_offset;
>  	head = data_offset - page_offset;
>  
> -	if (data_size && (data_offset + data_size < file_size))
> +	if (data_size == 0)
> +		goto out;
> +
> +	if (data_offset + data_size < file_size)
>  		file_size = data_offset + data_size;
>  
>  	ui_progress__init(&prog, file_size, "Processing events...");
> -- 
> 1.9.1

  reply	other threads:[~2015-09-16 20:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-16 17:18 [PATCH] perf tools: session: avoid infinite loop Mark Rutland
2015-09-16 20:54 ` Arnaldo Carvalho de Melo [this message]
2015-09-17 15:41   ` Mark Rutland
2015-09-18  6:09     ` Adrian Hunter
2015-09-18  9:51       ` Mark Rutland
2015-09-18 10:55         ` Adrian Hunter
2015-09-18 13:37           ` Mark Rutland
2015-09-18 15:00             ` Arnaldo Carvalho de Melo
2015-09-18 15:18               ` Mark Rutland
2015-09-18 15:29                 ` Arnaldo Carvalho de Melo
2015-09-21 12:33                   ` Adrian Hunter
2015-09-23  8:42 ` [tip:perf/core] perf record: Avoid infinite loop at buildid processing with no samples tip-bot for Mark Rutland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150916205454.GI11551@kernel.org \
    --to=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox