From: Jiri Olsa <jolsa@redhat.com>
To: David Carrillo-Cisneros <davidcc@google.com>
Cc: linux-kernel@vger.kernel.org,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Andi Kleen <ak@linux.intel.com>, Simon Que <sque@chromium.org>,
Wang Nan <wangnan0@huawei.com>, Jiri Olsa <jolsa@kernel.org>,
He Kuang <hekuang@huawei.com>,
Masami Hiramatsu <mhiramat@kernel.org>,
Stephane Eranian <eranian@google.com>,
Paul Turner <pjt@google.com>
Subject: Re: [PATCH 2/7] perf inject: copy events when reordering events in pipe mode
Date: Tue, 11 Apr 2017 11:40:50 +0200 [thread overview]
Message-ID: <20170411094050.GA21238@krava> (raw)
In-Reply-To: <20170410201432.24807-3-davidcc@google.com>
On Mon, Apr 10, 2017 at 01:14:27PM -0700, David Carrillo-Cisneros wrote:
> __perf_session__process_pipe_events reuses the same memory buffer to
> process all events in the pipe.
>
> When reordering is needed (e.g. -b option), events are not immediately
> flushed, but kept around until reordering is possible, causing
> memory corruption.
>
> The problem is usually observed by a "Unknown sample error" output. It
> can easily be reproduced by:
>
> perf record -o - noploop | perf inject -b > output
>
> Signed-off-by: David Carrillo-Cisneros <davidcc@google.com>
> ---
> tools/perf/util/ordered-events.c | 3 ++-
> tools/perf/util/session.c | 1 +
> 2 files changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/ordered-events.c b/tools/perf/util/ordered-events.c
> index fe84df1875aa..e70e935b1841 100644
> --- a/tools/perf/util/ordered-events.c
> +++ b/tools/perf/util/ordered-events.c
> @@ -79,7 +79,7 @@ static union perf_event *dup_event(struct ordered_events *oe,
>
> static void free_dup_event(struct ordered_events *oe, union perf_event *event)
> {
> - if (oe->copy_on_queue) {
> + if (event && oe->copy_on_queue) {
> oe->cur_alloc_size -= event->header.size;
> free(event);
> }
> @@ -150,6 +150,7 @@ void ordered_events__delete(struct ordered_events *oe, struct ordered_event *eve
> list_move(&event->list, &oe->cache);
> oe->nr_events--;
> free_dup_event(oe, event->event);
> + event->event = NULL;
based on the changelog I understand the need for the change below,
but I dont get why do we need this cleanu and check above
thanks,
jirka
> }
>
> int ordered_events__queue(struct ordered_events *oe, union perf_event *event,
> diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
> index 24259bc2c598..a25302bc55a8 100644
> --- a/tools/perf/util/session.c
> +++ b/tools/perf/util/session.c
> @@ -1656,6 +1656,7 @@ static int __perf_session__process_pipe_events(struct perf_session *session)
> buf = malloc(cur_size);
> if (!buf)
> return -errno;
> + ordered_events__set_copy_on_queue(oe, true);
> more:
> event = buf;
> err = readn(fd, event, sizeof(struct perf_event_header));
> --
> 2.12.2.715.g7642488e1d-goog
>
next prev parent reply other threads:[~2017-04-11 9:40 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-10 20:14 [PATCH 0/7] perf tool: pipe-mode fixes David Carrillo-Cisneros
2017-04-10 20:14 ` [PATCH 1/7] perf inject: don't proceed if perf_session__process_event fails David Carrillo-Cisneros
2017-04-12 5:39 ` [tip:perf/core] perf inject: Don't proceed if perf_session__process_event() fails tip-bot for David Carrillo-Cisneros
2017-04-10 20:14 ` [PATCH 2/7] perf inject: copy events when reordering events in pipe mode David Carrillo-Cisneros
2017-04-11 9:40 ` Jiri Olsa [this message]
2017-04-11 18:56 ` David Carrillo-Cisneros
2017-04-12 5:39 ` [tip:perf/core] perf inject: Copy " tip-bot for David Carrillo-Cisneros
2017-04-10 20:14 ` [PATCH 3/7] perf tool: describe pipe mode in perf.data-file-fomat.txt David Carrillo-Cisneros
2017-04-12 5:40 ` [tip:perf/core] perf tools: Describe " tip-bot for David Carrillo-Cisneros
2017-04-10 20:14 ` [PATCH 4/7] perf annotate: process attr and build_id records David Carrillo-Cisneros
2017-04-12 5:40 ` [tip:perf/core] perf annotate: Process " tip-bot for David Carrillo-Cisneros
2017-04-10 20:14 ` [PATCH 5/7] perf session: don't rely on evlist in pipe mode David Carrillo-Cisneros
2017-04-11 18:40 ` Arnaldo Carvalho de Melo
2017-04-11 18:40 ` Arnaldo Carvalho de Melo
2017-04-11 18:44 ` Arnaldo Carvalho de Melo
2017-04-11 18:59 ` David Carrillo-Cisneros
2017-04-11 19:44 ` Arnaldo Carvalho de Melo
2017-04-12 5:41 ` [tip:perf/core] perf session: Don't " tip-bot for David Carrillo-Cisneros
2017-04-10 20:14 ` [PATCH 6/7] perf tool: protect empty evlists David Carrillo-Cisneros
2017-04-11 18:12 ` Arnaldo Carvalho de Melo
2017-04-11 18:34 ` David Carrillo-Cisneros
2017-04-10 20:14 ` [PATCH 7/7] perf tool: do not print missing features in pipe-mode David Carrillo-Cisneros
2017-04-12 5:41 ` [tip:perf/core] perf tools: Do " tip-bot for David Carrillo-Cisneros
2017-04-11 9:49 ` [PATCH 0/7] perf tool: pipe-mode fixes Jiri Olsa
2017-04-11 18:17 ` Arnaldo Carvalho de Melo
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=20170411094050.GA21238@krava \
--to=jolsa@redhat.com \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=davidcc@google.com \
--cc=eranian@google.com \
--cc=hekuang@huawei.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=pjt@google.com \
--cc=sque@chromium.org \
--cc=wangnan0@huawei.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.