Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1621100
| From | Jiri Olsa <jolsa@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 2/7] perf inject: copy events when reordering events in pipe mode |
| Date | 2017-04-11 11:50 +0200 |
| Message-ID | <tv0AV-5dh-15@gated-at.bofh.it> (permalink) |
| References | <tuNX3-5AE-3@gated-at.bofh.it> <tuNX4-5AE-43@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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
>
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/7] perf tool: pipe-mode fixes David Carrillo-Cisneros <davidcc@google.com> - 2017-04-10 22:20 +0200
[PATCH 1/7] perf inject: don't proceed if perf_session__process_event fails David Carrillo-Cisneros <davidcc@google.com> - 2017-04-10 22:20 +0200
[tip:perf/core] perf inject: Don't proceed if perf_session__process_event() fails tip-bot for David Carrillo-Cisneros <tipbot@zytor.com> - 2017-04-12 07:50 +0200
[PATCH 2/7] perf inject: copy events when reordering events in pipe mode David Carrillo-Cisneros <davidcc@google.com> - 2017-04-10 22:20 +0200
Re: [PATCH 2/7] perf inject: copy events when reordering events in pipe mode Jiri Olsa <jolsa@redhat.com> - 2017-04-11 11:50 +0200
Re: [PATCH 2/7] perf inject: copy events when reordering events in pipe mode David Carrillo-Cisneros <davidcc@google.com> - 2017-04-11 21:00 +0200
[tip:perf/core] perf inject: Copy events when reordering events in pipe mode tip-bot for David Carrillo-Cisneros <tipbot@zytor.com> - 2017-04-12 07:50 +0200
[PATCH 4/7] perf annotate: process attr and build_id records David Carrillo-Cisneros <davidcc@google.com> - 2017-04-10 22:20 +0200
[tip:perf/core] perf annotate: Process attr and build_id records tip-bot for David Carrillo-Cisneros <tipbot@zytor.com> - 2017-04-12 07:50 +0200
[PATCH 6/7] perf tool: protect empty evlists David Carrillo-Cisneros <davidcc@google.com> - 2017-04-10 22:20 +0200
Re: [PATCH 6/7] perf tool: protect empty evlists Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-04-11 20:20 +0200
Re: [PATCH 6/7] perf tool: protect empty evlists David Carrillo-Cisneros <davidcc@google.com> - 2017-04-11 20:40 +0200
[PATCH 7/7] perf tool: do not print missing features in pipe-mode David Carrillo-Cisneros <davidcc@google.com> - 2017-04-10 22:20 +0200
[tip:perf/core] perf tools: Do not print missing features in pipe-mode tip-bot for David Carrillo-Cisneros <tipbot@zytor.com> - 2017-04-12 07:50 +0200
[PATCH 5/7] perf session: don't rely on evlist in pipe mode David Carrillo-Cisneros <davidcc@google.com> - 2017-04-10 22:20 +0200
Re: [PATCH 5/7] perf session: don't rely on evlist in pipe mode Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-04-11 20:50 +0200
Re: [PATCH 5/7] perf session: don't rely on evlist in pipe mode David Carrillo-Cisneros <davidcc@google.com> - 2017-04-11 21:00 +0200
Re: [PATCH 5/7] perf session: don't rely on evlist in pipe mode Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-04-11 21:50 +0200
Re: [PATCH 5/7] perf session: don't rely on evlist in pipe mode Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-04-11 20:50 +0200
Re: [PATCH 5/7] perf session: don't rely on evlist in pipe mode Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-04-11 20:50 +0200
[tip:perf/core] perf session: Don't rely on evlist in pipe mode tip-bot for David Carrillo-Cisneros <tipbot@zytor.com> - 2017-04-12 07:50 +0200
Re: [PATCH 0/7] perf tool: pipe-mode fixes Jiri Olsa <jolsa@redhat.com> - 2017-04-11 11:50 +0200
Re: [PATCH 0/7] perf tool: pipe-mode fixes Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-04-11 20:20 +0200
csiph-web