Re: perf support user-space hw_breakpoint?

From: Jovi Zhang
Date: Wed Jun 27 2012 - 21:01:59 EST


Hi

On Mon, Jun 25, 2012 at 4:26 PM, Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
> Hi, Jovi
>
> On Mon, 25 Jun 2012 13:22:01 +0800, Jovi Zhang wrote:
>> Hi guys,
>>
>> Does perf support user space hw_breakpoint based on per-task?
>>
>> perf already support kenerl space hw_breakpoint, but there don't have
>> any example for
>> user-space hw_breakpoint in code base(and never metion it).
>> From perf api point of view, it should support per-task hw_breakpoint easily.
>> but I still want to make sure that?(badly I don't have any linux
>> machine to test it now:))
>>
>
> Here is my simple test:
>
> namhyung@sejong:perf$ nm -nD /usr/bin/ls | grep D
> 0000000000619ce0 D quoting_style_args
> 000000000061a530 D ls_mode
> 000000000061a538 D Version
> 000000000061a540 D argmatch_die
> 000000000061a548 D exit_failure
>
> namhyung@sejong:perf$ ./perf stat -e mem:0x61a530 -e mem:0x61a538 -- /usr/bin/ls > /dev/null
>
> ÂPerformance counter stats for '/usr/bin/ls':
>
> Â Â Â Â Â Â Â Â 1 mem:0x61a530:rw
> Â Â Â Â Â Â Â Â 0 mem:0x61a538:rw
>
> Â Â Â 0.002213595 seconds time elapsed
>
>
> So, it should work on user-space hw_breakpoints.

Thanks very much, it works.

>
> BTW, when I perf record on a hwbp, it failed with ENOSPC.
> I guess it's because each per-task-per-cpu event tried to
> create an event so it'd get more than supported by h/w.
> The strace told me that the fifth call to perf_event_open
> failed on my 6-core machine.
>
> Thanks,
> Namhyung

I have same result as you in my linux box.
This should be a bug cause by commit d1cb9f(perf target: Add uses_mmap field)

Namhyung, How about below patch?