Re: [tip:perf/core] perf: Add non-exec mmap() tracking

From: Pekka Enberg
Date: Wed Jun 09 2010 - 08:53:21 EST


On Wed, Jun 9, 2010 at 3:22 PM, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> On Wed, 2010-06-09 at 13:44 +0300, Pekka Enberg wrote:
>> > @@ -3830,6 +3834,14 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
>> >                if (!vma->vm_mm) {
>> >                        name = strncpy(tmp, "[vdso]", sizeof(tmp));
>> >                        goto got_name;
>> > +               } else if (vma->vm_start <= vma->vm_mm->start_brk &&
>> > +                               vma->vm_end >= vma->vm_mm->brk) {
>> > +                       name = strncpy(tmp, "[heap]", sizeof(tmp));
>> > +                       goto got_name;
>> > +               } else if (vma->vm_start <= vma->vm_mm->start_stack &&
>> > +                               vma->vm_end >= vma->vm_mm->start_stack) {
>> > +                       name = strncpy(tmp, "[stack]", sizeof(tmp));
>> > +                       goto got_name;
>> >                }
>> >
>> >                name = strncpy(tmp, "//anon", sizeof(tmp));
>>
>> Doesn't this change here break the JIT generated code region detection
>> in map__new() of tools/perf/util/map.c? We generate a new
>> "/tmp/perf-<pid>.map" filename for anonymous memory regions and check
>> for that in dso__load() of tools/perf/util/symbol.c.
>
> Not unless you stick your executable code in the heap or on the stack.

Right, I misread the patch. Thanks for the clarification, Peter!

> If you use something like mmap(NULL, size, PROT_READ|PROT_WRITE|
> PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); to allocate your memory
> everything should be fine.

Sure, that's what I do.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/