From: Ingo Molnar <mingo@kernel.org>
To: David Ahern <dsahern@gmail.com>
Cc: acme@ghostprotocols.net, linux-kernel@vger.kernel.org,
Frederic Weisbecker <fweisbec@gmail.com>,
Peter Zijlstra <peterz@infradead.org>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
Stephane Eranian <eranian@google.com>
Subject: Re: [PATCH] perf: detect loops processing events
Date: Thu, 9 May 2013 11:24:41 +0200 [thread overview]
Message-ID: <20130509092441.GB21620@gmail.com> (raw)
In-Reply-To: <1368026327-4741-1-git-send-email-dsahern@gmail.com>
* David Ahern <dsahern@gmail.com> wrote:
> Recovery algorithm in __perf_session__process_events attempts to remap
> a perf.data file with a different file_offset and try again at a new head
> position. Both of these adjustment rely on page_offset. If page_offset is
> 0 then file_offset and head never change which means the remap attempt is
> the same and the fetch_mmaped_event is the same and the processing just
> loops forever.
>
> Detect this condition and warn the user.
>
> Signed-off-by: David Ahern <dsahern@gmail.com>
> Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Jiri Olsa <jolsa@redhat.com>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Stephane Eranian <eranian@google.com>
> ---
> tools/perf/util/session.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
> index cf1fe01..1c4dc45 100644
> --- a/tools/perf/util/session.c
> +++ b/tools/perf/util/session.c
> @@ -1235,6 +1235,12 @@ more:
> }
>
> page_offset = page_size * (head / page_size);
> + /* catch looping where we never make forward progress. */
> + if (page_offset == 0) {
> + pr_err("Loop detection processing events. Is file corrupted?\n");
> + return -1;
> + }
> +
> file_offset += page_offset;
> head -= page_offset;
> goto remap;
Ah, nice!
Btw., would it make sense to emit a (once-only) warning and optimistically
fix page_offset up to 1 (or 4096) and let things continue with the next
set of data - can we recover most of the data in that case?
Thanks,
Ingo
next prev parent reply other threads:[~2013-05-09 9:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-08 15:18 [PATCH] perf: detect loops processing events David Ahern
2013-05-09 9:24 ` Ingo Molnar [this message]
2013-05-09 9:30 ` Ingo Molnar
2013-05-10 1:10 ` Namhyung Kim
2013-05-10 1:40 ` David Ahern
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=20130509092441.GB21620@gmail.com \
--to=mingo@kernel.org \
--cc=acme@ghostprotocols.net \
--cc=dsahern@gmail.com \
--cc=eranian@google.com \
--cc=fweisbec@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=namhyung@kernel.org \
--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