From: Wang Nan <wangnan0@huawei.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: <jolsa@kernel.org>, <namhyung@kernel.org>, <mingo@redhat.com>,
<lizefan@huawei.com>, <pi3orama@163.com>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 2/2] perf: report/annotate: fix segfault problem.
Date: Wed, 8 Apr 2015 11:49:47 +0800 [thread overview]
Message-ID: <5524A55B.4050707@huawei.com> (raw)
In-Reply-To: <20150407151322.GK11983@kernel.org>
On 2015/4/7 23:13, Arnaldo Carvalho de Melo wrote:
> Em Tue, Apr 07, 2015 at 08:22:46AM +0000, Wang Nan escreveu:
>> perf report and perf annotate are easy to trigger segfault if trace data
>> contain 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]
>
> So, with this patch applied I am seeing this:
>
> [root@ssdandy ~]# perf sched record -a
> Kmod (modules.order) and cpumode (0) inconsistent
> Kmod (modules.builtin) and cpumode (0) inconsistent
> Kmod (modules.dep) and cpumode (0) inconsistent
> Kmod (modules.dep.bin) and cpumode (0) inconsistent
> Kmod (modules.alias) and cpumode (0) inconsistent
> Kmod (modules.alias.bin) and cpumode (0) inconsistent
> Kmod (modules.softdep) and cpumode (0) inconsistent
> Kmod (modules.symbols) and cpumode (0) inconsistent
> Kmod (modules.symbols.bin) and cpumode (0) inconsistent
> Kmod (modules.builtin.bin) and cpumode (0) inconsistent
> Kmod (modules.devname) and cpumode (0) inconsistent
> ^C[ perf record: Woken up 1 times to write data ]
> [ perf record: Captured and wrote 0.465 MB perf.data (1595 samples) ]
>
> [root@ssdandy ~]#o
>
> Can you please check this?
>
> Why do we get these warning for these files?
>
This is because in map_groups__set_modules_path_dir() we enumerate over each file
in /lib/modules/`uname -a`/ and use kmod_path__parse_name() to parse their names.
In this v3 patch, I update __kmod_path__parse() to check consistency between m.kmod and
cpumode. It will warn if one passes a kernel module name with user
space cpumode, or passes kernel space cpumode with a non-kmodule name.
I'll post a patch v4 to avoid such warning if passed cpumode is not explicitly set to
user or kernel.
Difference from v3:
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index fb1ed7d..875f7c9 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -215,7 +215,7 @@ int __kmod_path__parse(struct kmod_path *m, const char *path,
const char *name = strrchr(path, '/');
const char *ext = strrchr(path, '.');
bool is_simple_name = false;
- bool cpu_mode_kernel, is_kernel = false;
+ bool cpu_mode_kernel, cpu_mode_unknown = false, is_kernel = false;
/* treat PERF_RECORD_MISC_CPUMODE_UNKNOWN as kernel. */
switch (cpumode & PERF_RECORD_MISC_CPUMODE_MASK) {
@@ -224,6 +224,9 @@ int __kmod_path__parse(struct kmod_path *m, const char *path,
case PERF_RECORD_MISC_GUEST_USER:
cpu_mode_kernel = false;
break;
+ case PERF_RECORD_MISC_CPUMODE_UNKNOWN:
+ cpu_mode_unknown = true;
+ /* fall through */
default:
cpu_mode_kernel = true;
}
@@ -288,10 +291,12 @@ int __kmod_path__parse(struct kmod_path *m, const char *path,
}
}
out:
- if ((m->kmod && !cpu_mode_kernel) ||
- (cpu_mode_kernel && !m->kmod && !is_kernel))
- pr_warning("Kmod (%s) and cpumode (%d) inconsistent\n",
- path, cpumode);
+ if (!cpu_mode_unknown) {
+ if ((m->kmod && !cpu_mode_kernel) ||
+ (cpu_mode_kernel && !m->kmod && !is_kernel))
+ pr_warning("Kmod (%s) and cpumode (%d) inconsistent\n",
+ path, cpumode);
+ }
return 0;
}
>
> Applied the other patch:
>
> -> 28 T 04/07 Wang Nan (8,8K) [PATCH v3 1/2] perf: kmaps: enforce usage of kmaps to protect futher bugs.
>
>
> - Arnaldo
>
next prev parent reply other threads:[~2015-04-08 3:50 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-03 5:56 [PATCH v2] perf: report/annotate: fix segfault problem Wang Nan
2015-04-03 6:48 ` Ingo Molnar
2015-04-03 8:47 ` [PATCH] perf: kmaps: enforce usage of kmaps to protect futher bugs Wang Nan
2015-04-03 8:49 ` Ingo Molnar
2015-04-03 11:11 ` Jiri Olsa
2015-04-07 10:42 ` Adrian Hunter
2015-04-08 10:50 ` [PATCH v4] " Wang Nan
2015-04-03 9:07 ` [PATCH v2] perf: report/annotate: fix segfault problem Jiri Olsa
2015-04-03 10:57 ` Jiri Olsa
2015-04-06 12:52 ` Arnaldo Carvalho de Melo
2015-04-07 8:22 ` [PATCH v3 0/2] " Wang Nan
2015-04-07 8:22 ` [PATCH v3 1/2] perf: kmaps: enforce usage of kmaps to protect futher bugs Wang Nan
2015-04-08 15:10 ` [tip:perf/core] perf kmaps: Check kmaps to make code more robust tip-bot for Wang Nan
2015-04-07 8:22 ` [PATCH v3 2/2] perf: report/annotate: fix segfault problem Wang Nan
2015-04-07 15:13 ` Arnaldo Carvalho de Melo
2015-04-08 3:49 ` Wang Nan [this message]
2015-04-08 3:52 ` [PATCH v4 " Wang Nan
2015-04-08 13:59 ` Jiri Olsa
2015-04-09 7:05 ` Wang Nan
2015-04-09 11:40 ` Jiri Olsa
2015-04-09 11:52 ` Jiri Olsa
2015-04-10 1:57 ` Wang Nan
2015-04-10 2:49 ` Wang Nan
2015-04-10 3:53 ` [PATCH v5 " Wang Nan
2015-04-15 1:27 ` Wang Nan
2015-04-20 1:18 ` Wang Nan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5524A55B.4050707@huawei.com \
--to=wangnan0@huawei.com \
--cc=acme@kernel.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan@huawei.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=pi3orama@163.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.