2011/3/28 David Ahern <[email protected]>:
>
>
> On 03/27/11 01:44, zhao bao wrote:
>> The address I want is the value stored in X86 CR2 register when page
>> fault occurs, Does perf provide these information?
>
> Add the -d option to perf-record, and try the following change on
> perf-script:
>
> diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> index ac574ea..85376b7 100644
> --- a/tools/perf/builtin-script.c
> +++ b/tools/perf/builtin-script.c
> @@ -32,6 +32,7 @@ enum perf_output_field {
> PERF_OUTPUT_EVNAME = 1U << 5,
> PERF_OUTPUT_TRACE = 1U << 6,
> PERF_OUTPUT_SYM = 1U << 7,
> + PERF_OUTPUT_ADDR = 1U << 8,
> };
>
> struct output_option {
> @@ -46,6 +47,7 @@ struct output_option {
> {.str = "event", .field = PERF_OUTPUT_EVNAME},
> {.str = "trace", .field = PERF_OUTPUT_TRACE},
> {.str = "sym", .field = PERF_OUTPUT_SYM},
> + {.str = "addr", .field = PERF_OUTPUT_ADDR},
> };
>
> /* default set to maintain compatibility with current format */
> @@ -158,6 +160,8 @@ static void print_sample_start(struct perf_sample
> *sample,
>
> printf("%s: ", evname ? evname : "(unknown)");
> }
> + if (PRINT_FIELD(ADDR))
> + printf("0x%" PRIx64, sample->addr);
> }
>
> static void process_event(union perf_event *event __unused,
> @@ -829,7 +833,7 @@ static const struct option options[] = {
> OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
> "Look for files with symbols relative to this directory"),
> OPT_CALLBACK('f', "fields", NULL, "str",
> - "comma separated output fields prepend with 'type:'. Valid
> types: hw,sw,trace. Fields: comm,tid,pid,time,cpu,event,trace,sym",
> + "comma separated output fields prepend with 'type:'. Valid
> types: hw,sw,trace. Fields: comm,tid,pid,time,cpu,event,trace,sym,addr",
> parse_output_fields),
>
> OPT_END()
>
>
>>
I applyed this patch in the builtin-script.c , recompile and install
it. But I found it still doesn't show any CR2 address info. The patch
seems to list a addr column, but perf script still work as before.
I tried two ways.
(1) In fedora 14, new "/root/bin/perf record -d" cannot work because
of "-d" option, so I use old perf record (perf version
2.6.35.6-45.fc14.i686), then use new "perf script" , result is still
the same as before.
[root@localhost lab]# perf --version
perf version 2.6.35.6-45.fc14.i686
[root@localhost lab]# /root/bin/perf --version
perf version 2.6.38.2972.gf88210.dirty
[root@localhost lab]# /root/bin/perf record -c 1 -e faults -R -d ./hello
Error: sys_perf_event_open() syscall returned with 22 (Invalid
argument). /bin/dmesg may provide additional information.
Fatal: No CONFIG_PERF_EVENTS=y kernel support configured?
[root@localhost lab]# perf record -c 1 -e faults -R -d ./hello
hello,world
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.010 MB perf.data (~415 samples) ]
[root@localhost lab]# /root/bin/perf script
hello 2924 [000] 1422.290866: page-faults:
c05b6d35 clear_user ([kernel.kallsyms])
hello 2924 [000] 1422.290894: page-faults:
c05b6d35 clear_user ([kernel.kallsyms])
hello 2924 [000] 1422.290910: page-faults:
c05b68a0 __copy_to_user_ll ([kernel.kallsyms])
hello 2924 [000] 1422.290946: page-faults:
870 _start (/lib/ld-2.13.so)
(2) I compiled the 2.6.38.rc6 kernel(I downloaded a month ago) ,
reboot machien. Now new "/root/bin/perf record -d" can work, but new
"perf script" shows no change.
[root@localhost lab]# /root/bin/perf record -c 1 -e faults -R -d ./hello
hello,world
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.013 MB perf.data (~557 samples) ]
[root@localhost lab]# /root/bin/perf script
hello 2229 [000] 1339.388865: page-faults:
c05ccbb3 clear_user ([kernel.kallsyms])
hello 2229 [000] 1339.388898: page-faults:
c05ccbb3 clear_user ([kernel.kallsyms])
hello 2229 [000] 1339.388915: page-faults:
c05cc70c __copy_to_user_ll ([kernel.kallsyms])
hello 2229 [000] 1339.388945: page-faults:
870 _start (/lib/ld-2.13.so)
hello 2229 [000] 1339.388950: page-faults:
4920 _dl_start (/lib/ld-2.13.so)
hello 2229 [000] 1339.388954: page-faults:
17acb __i686.get_pc_thunk.bx (/lib/ld-2.13.so)
--
To unsubscribe from this list: send the line "unsubscribe linux-perf-users" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html