lkml.org 
[lkml]   [2019]   [Jul]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v1] perf session: fix loading of compressed data split across adjacent records
From
Date
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 - :)

~Alexey

>
> otherwise it lookgs good to me
>
> thanks,
> jirka
>

\
 
 \ /
  Last update: 2019-07-15 14:31    [W:0.084 / U:47.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site