Re: perf support user-space hw_breakpoint?

From: Namhyung Kim
Date: Wed Jun 27 2012 - 22:23:58 EST


On Thu, 28 Jun 2012 09:02:02 +0800, Jovi Zhang wrote:
> On Mon, Jun 25, 2012 at 4:26 PM, Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
>> 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.
>>
> 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?
>

NAK. This uses_mmap field is needed to setup per-task-per-cpu events for
perf record (mostly). Without it, perf suffered from severe scalability
issues. Maybe we can change it not to create per-task-per-cpu events iff
for hwbp events only, but I'm not sure it's the right thing.

Thanks,
Namhyung


>
> From 4b77b99df9ca3b99be4ccf8c4256e622aae9203f Mon Sep 17 00:00:00 2001
> From: Jovi Zhang <bookjovi@xxxxxxxxx>
> Date: Thu, 28 Jun 2012 07:49:41 +0800
> Subject: [PATCH] perf: revert commit d1cb9f(perf target: Add uses_mmap field)
>
> In my x86 4 cores cpu linux machine, using hw_breakpoint output as follows:
>
> Before add uses_mmap field:
> Â[root@jovi perf]# ./perf record -g -e mem:0x080652c8 -e mem:0x1098 --
> /usr/bin/ls >/dev/null
> Â[ perf record: Woken up 1 times to write data ]
> Â[ perf record: Captured and wrote 0.015 MB perf.data (~640 samples) ]
>
> After add uses_mmap field:
> Â[root@jovi perf]# ./perf record -e mem:0x080652c8 -e mem:0x1098 --
> /usr/bin/ls >/dev/null
> Â ÂError: sys_perf_event_open() syscall returned with 28 (No space
> left on device). Â/bin/dmesg may provide additional information.
>
> Â ÂFatal: No CONFIG_PERF_EVENTS=y kernel support configured?
>
> Adding uses_mmap field in target structure will cause perf-record
> creat per-task-per-cpu
> event for each evsel, this will break hw_breakpoint(have limit debug
> registers in cpu),
> in above example, we should create dummy cpumap for hw_breakpoint
> event, not per-task-per-cpu,
> fix it.
>
> Noticed-by: Namhyung Kim <namhyung@xxxxxxxxxx>
> Signed-off-by: Jovi Zhang <bookjovi@xxxxxxxxx>
> ---
> tools/perf/builtin-record.c | Â Â3 ---
> tools/perf/builtin-test.c  |  Â1 -
> tools/perf/builtin-top.c  Â|  Â3 ---
> tools/perf/util/evlist.c  Â|  Â4 +---
> tools/perf/util/target.h  Â|  Â1 -
> 5 files changed, 1 insertion(+), 11 deletions(-)
>
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index f95840d..8128213 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -754,9 +754,6 @@ static struct perf_record record = {
>        Â.user_freq      = UINT_MAX,
>        Â.user_interval    = ULLONG_MAX,
>        Â.freq        Â= 4000,
> -        .target       Â= {
> -            .uses_mmap  = true,
> - Â Â Â Â Â Â Â },
> Â Â Â Â},
> Â Â Â Â.write_mode = WRITE_FORCE,
>    Â.file_new  = true,
> diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c
> index 5a8727c..338a0cc 100644
> --- a/tools/perf/builtin-test.c
> +++ b/tools/perf/builtin-test.c
> @@ -647,7 +647,6 @@ static int test__PERF_RECORD(void)
> Â Â Â Âstruct perf_record_opts opts = {
> Â Â Â Â Â Â Â Â.target = {
> Â Â Â Â Â Â Â Â Â Â Â Â.uid = UINT_MAX,
> - Â Â Â Â Â Â Â Â Â Â Â .uses_mmap = true,
> Â Â Â Â Â Â Â Â},
>        Â.no_delay  = true,
>        Â.freq    = 10,
> diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
> index 6bb0277..cc78e06 100644
> --- a/tools/perf/builtin-top.c
> +++ b/tools/perf/builtin-top.c
> @@ -1165,9 +1165,6 @@ int cmd_top(int argc, const char **argv, const
> char *prefix __used)
>        Â.freq        Â= 4000, /* 4 KHz */
>        Â.mmap_pages     Â= 128,
>        Â.sym_pcnt_filter   = 5,
> -        .target       Â= {
> -            .uses_mmap  = true,
> - Â Â Â Â Â Â Â },
> Â Â Â Â};
> Â Â Â Âchar callchain_default_opt[] = "fractal,0.5,callee";
> Â Â Â Âconst struct option options[] = {
> diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
> index 7400fb3..e791029 100644
> --- a/tools/perf/util/evlist.c
> +++ b/tools/perf/util/evlist.c
> @@ -622,9 +622,7 @@ int perf_evlist__create_maps(struct perf_evlist *evlist,
> Â Â Â Âif (evlist->threads == NULL)
> Â Â Â Â Â Â Â Âreturn -1;
>
> - Â Â Â if (perf_target__has_task(target))
> - Â Â Â Â Â Â Â evlist->cpus = cpu_map__dummy_new();
> - Â Â Â else if (!perf_target__has_cpu(target) && !target->uses_mmap)
> + Â Â Â if (perf_target__has_task(target) || !perf_target__has_cpu(target))
> Â Â Â Â Â Â Â Âevlist->cpus = cpu_map__dummy_new();
> Â Â Â Âelse
> Â Â Â Â Â Â Â Âevlist->cpus = cpu_map__new(target->cpu_list);
> diff --git a/tools/perf/util/target.h b/tools/perf/util/target.h
> index a4be857..c43f632 100644
> --- a/tools/perf/util/target.h
> +++ b/tools/perf/util/target.h
> @@ -11,7 +11,6 @@ struct perf_target {
>    Âconst char  *uid_str;
>    Âuid_t    Âuid;
>    Âbool     system_wide;
> -    bool     uses_mmap;
> };
>
> enum perf_target_errno {
> --
> 1.7.9.7
--
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/