[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1c950a87-2224-080e-329e-cf9536ccef02@linux.intel.com>
Date: Tue, 28 Aug 2018 13:28:30 +0300
From: Alexey Budankov <alexey.budankov@...ux.intel.com>
To: Jiri Olsa <jolsa@...hat.com>
Cc: Ingo Molnar <mingo@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Namhyung Kim <namhyung@...nel.org>,
Andi Kleen <ak@...ux.intel.com>,
linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v3 2/2]: perf record: enable asynchronous trace writing
Hi,
On 28.08.2018 11:53, Jiri Olsa wrote:
> On Mon, Aug 27, 2018 at 09:16:55PM +0300, Alexey Budankov wrote:
>
> SNIP
>
>> if ((md->start & md->mask) + size != (md->end & md->mask)) {
>> buf = &data[md->start & md->mask];
>> - size = md->mask + 1 - (md->start & md->mask);
>> - md->start += size;
>> -
>> - if (push(to, buf, size) < 0) {
>> - rc = -1;
>> - goto out;
>> - }
>> + size0 = md->mask + 1 - (md->start & md->mask);
>> + md->start += size0;
>> + memcpy(md->data, buf, size0);
>> }
>>
>> buf = &data[md->start & md->mask];
>> size = md->end - md->start;
>> md->start += size;
>> + memcpy(md->data + size0, buf, size);
>>
>> - if (push(to, buf, size) < 0) {
>> - rc = -1;
>> + rc = push(to, md, size0 + size, *off) < 0 ? -1 : 1;
>> + if (rc == -1)
>> goto out;
>> - }
>> +
>> + perf_mmap__get(md);
>> + *off += size0 + size;
>
> this get is for the perf_mmap pointer storage in the mmap_aio array right?
Right. perf_mmap__get() here guards whole perf_mmap object and memory
referenced thru it from premature deallocation because mmap->base kernel
buffer can be released earlier than aio requests started on mmap->data
complete and the both buffers are referenced thru the same perf_mmap object.
>
> I see it's released in record__mmap_read_sync, which might also return
> without releasing it.. this needs to be fixed and explained in here,
> why we take the reference in the first place
So we increment after successful push() from map->base to map->data
with following aio_write() and decrement when aio_write() is fully
complete, because it may require restart if the kernel didn't write
whole chunk at once.
Probably we are still missing one more perf_mmap__put() after:
pr_err("failed to write perf data, error: %m\n");
prior nullifying the appropriate cblock.
Updated [PATCH v4 2/2]:
- Written comment in perf_mmap__push() just before perf_mmap__get();
- Written comment in record__mmap_read_sync() on possible restarting
of aio_write() operation and releasing perf_mmap object after all;
- added perf_mmap__put() for the cases of failed aio_write();
Thanks!
>
> thanks,
> jirka
>
Powered by blists - more mailing lists