Re: [PATCH v1] perf session: fix loading of compressed data split across adjacent records
From: Arnaldo Carvalho de Melo
Date: Wed Jul 17 2019 - 08:34:58 EST
Em Tue, Jul 16, 2019 at 10:59:30PM +0200, Jiri Olsa escreveu:
> On Tue, Jul 16, 2019 at 03:49:59PM -0300, Arnaldo Carvalho de Melo wrote:
> > Em Mon, Jul 15, 2019 at 03:30:24PM +0300, Alexey Budankov escreveu:
> > > On 14.07.2019 18:49, Jiri Olsa wrote:
> > > > On Tue, Jul 09, 2019 at 05:48:14PM +0300, Alexey Budankov wrote:
> > > >
> > > > SNIP
> > > >
> > > >> decomp->file_pos = file_offset;
> > > >> + decomp->mmap_len = mmap_len;
> > > >> decomp->head = 0;
> > > >>
> > > >> - if (decomp_last) {
> > > >> - decomp_last_rem = decomp_last->size - decomp_last->head;
> > > >> + if (decomp_last_rem) {
> > > >> memcpy(decomp->data, &(decomp_last->data[decomp_last->head]), decomp_last_rem);
> > > >> decomp->size = decomp_last_rem;
> > > >> }
> > > >> @@ -61,7 +67,7 @@ static int perf_session__process_compressed_event(struct perf_session *session,
> > > >> decomp_size = zstd_decompress_stream(&(session->zstd_data), src, src_size,
> > > >> &(decomp->data[decomp_last_rem]), decomp_len - decomp_last_rem);
> > > >> if (!decomp_size) {
> > > >> - munmap(decomp, sizeof(struct decomp) + decomp_len);
> > > >> + munmap(decomp, mmap_len);
> > > >> pr_err("Couldn't decompress data\n");
> > > >> return -1;
> > > >> }
> > > >> @@ -255,15 +261,15 @@ static void perf_session__delete_threads(struct perf_session *session)
> > > >> static void perf_session__release_decomp_events(struct perf_session *session)
> > > >> {
> > > >> struct decomp *next, *decomp;
> > > >> - size_t decomp_len;
> > > >> + size_t mmap_len;
> > > >> next = session->decomp;
> > > >> - decomp_len = session->header.env.comp_mmap_len;
> > > >> do {
> > > >> decomp = next;
> > > >> if (decomp == NULL)
> > > >> break;
> > > >> next = decomp->next;
> > > >> - munmap(decomp, decomp_len + sizeof(struct decomp));
> > > >> + mmap_len = decomp->mmap_len;
> > > >> + munmap(decomp, mmap_len);
> > > >
> > > > what's the need for extra mmap_len variable in here?
> > > > could you just use decomp->mmap_len directly?
> > >
> > > To avoid reference to the object being deallocated.
> > > Plain munmap(), yes - :)
>
> well it's passed as value, so should be ok,
> anyway I was just curious, if I'm not missing
> something else.. it's ok ;-)
>
> >
> > So, Jiri, Acked-by?
>
> yep ;-)
>
> Acked-by: Jiri Olsa <jolsa@xxxxxxxxxx>
Thanks, applied.
- Arnaldo