Re: [PATCH v6] perf: __kmod_path__parse: deal with kernel module names in '[]' correctly.
From: Wang Nan
Date: Tue Apr 21 2015 - 05:29:23 EST
On 2015/4/21 13:16, Namhyung Kim wrote:
> Hi Wang,
>
> On Tue, Apr 21, 2015 at 03:33:10AM +0000, Wang Nan wrote:
>> Before patch ba92732e9808df679ddf75c5ea1c0caae6d7dce2 ('perf kmaps:
>> Check kmaps to make code more robust'), perf report and perf annotate
>> will segfault if trace data contains kernel module information like
>> this:
>>
>> # perf report -D -i ./perf.data
>> ...
>> 0 0 0x188 [0x50]: PERF_RECORD_MMAP -1/0: [0xffffffbff1018000(0xf068000) @ 0]: x [test_module]
>> ...
>>
>> # perf report -i ./perf.data --objdump=/path/to/objdump --kallsyms=/path/to/kallsyms
>>
>> perf: Segmentation fault
>> -------- backtrace --------
>> /path/to/perf[0x503478]
>> /lib64/libc.so.6(+0x3545f)[0x7fb201f3745f]
>> /path/to/perf[0x499b56]
>> /path/to/perf(dso__load_kallsyms+0x13c)[0x49b56c]
>> /path/to/perf(dso__load+0x72e)[0x49c21e]
>> /path/to/perf(map__load+0x6e)[0x4ae9ee]
>> /path/to/perf(thread__find_addr_map+0x24c)[0x47deec]
>> /path/to/perf(perf_event__preprocess_sample+0x88)[0x47e238]
>> /path/to/perf[0x43ad02]
>> /path/to/perf[0x4b55bc]
>> /path/to/perf(ordered_events__flush+0xca)[0x4b57ea]
>> /path/to/perf[0x4b1a01]
>> /path/to/perf(perf_session__process_events+0x3be)[0x4b428e]
>> /path/to/perf(cmd_report+0xf11)[0x43bfc1]
>> /path/to/perf[0x474702]
>> /path/to/perf(main+0x5f5)[0x42de95]
>> /lib64/libc.so.6(__libc_start_main+0xf4)[0x7fb201f23bd4]
>> /path/to/perf[0x42dfc4]
>>
>> This is because __kmod_path__parse treats '[' leading names as kernel
>> name instead of names of kernel module. If perf.data contains build
>> information and the buildid of such modules can be found, the DSO of
>> it will be treated as kernel, not kernel module.
>
> Sorry if I missed some prior discussion on it, but any chance to treat
> them as modules instead of kernel binaries?
>
> Thanks,
> Namhyung
>
>
Sorry, I tried but failed to understand your question. What this patch do
is to treat them as modules instead of kernel binaries (or binary?
since kernel is a whole binary and kernel modules are DSOs).
[SNIP]
>> + /* path alloc_name alloc_ext kmod comp name ext */
>> + T("[test_module]", true , true , true, false, "[test_module]", NULL);
>> + T("[test_module]", false , true , true, false, NULL , NULL);
>> + T("[test_module]", true , false , true, false, "[test_module]", NULL);
>> + T("[test_module]", false , false , true, false, NULL , NULL);
>> + M("[test_module]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true);
>> + M("[test_module]", PERF_RECORD_MISC_KERNEL, true);
>> + M("[test_module]", PERF_RECORD_MISC_USER, false);
Before this patch, these testcases will return kmod == false result.
Thanks.
--
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/