[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <48431c29-5642-c282-a760-c2dd99db8049@linux.intel.com>
Date: Tue, 28 Aug 2018 12:19:06 +0300
From: Alexey Budankov <alexey.budankov@...ux.intel.com>
To: Jiri Olsa <jolsa@...hat.com>
Cc: Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...nel.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>,
linux-perf-users@...r.kernel.org
Subject: Re: [PATCH v2 1/2]: perf util: map data buffer for preserving
collected data
Hi,
On 28.08.2018 11:45, Jiri Olsa wrote:
> On Mon, Aug 27, 2018 at 12:02:35PM +0300, Alexey Budankov wrote:
>> Hi,
>>
>> On 27.08.2018 11:33, Jiri Olsa wrote:
>>> On Thu, Aug 23, 2018 at 07:42:09PM +0300, Alexey Budankov wrote:
>>>
>>> SNIP
>>>
>>>> diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c
>>>> index fc832676a798..e71d46cb01cc 100644
>>>> --- a/tools/perf/util/mmap.c
>>>> +++ b/tools/perf/util/mmap.c
>>>> @@ -155,6 +155,10 @@ void __weak auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp __mayb
>>>>
>>>> void perf_mmap__munmap(struct perf_mmap *map)
>>>> {
>>>> + if (map->data != NULL) {
>>>> + munmap(map->data, perf_mmap__mmap_len(map));
>>>> + map->data = NULL;
>>>> + }
>>>> if (map->base != NULL) {
>>>> munmap(map->base, perf_mmap__mmap_len(map));
>>>> map->base = NULL;
>>>> @@ -190,6 +194,14 @@ int perf_mmap__mmap(struct perf_mmap *map, struct mmap_params *mp, int fd)
>>>> map->base = NULL;
>>>> return -1;
>>>> }
>>>> + map->data = mmap(NULL, perf_mmap__mmap_len(map), PROT_READ | PROT_WRITE,
>>>> + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
>>>
>>> hum, why does map->data need to be mmap-ed?
>>
>> The same way as for kernel buffers. If you see better alternatives it could be applied.
>
> I meant why not just allocate them with mmaloc?
Yep. Using malloc()/free() makes the implementation shorter. Included into [PATCH v4 1/2].
>
> jirka
>
Powered by blists - more mailing lists