Skip to content

Commit fd786fa

Browse files
WangNan0acmel
authored andcommitted
perf buildid: Fix cpumode of buildid event
There is a nasty confusion that, for kernel module, dso->kernel is not necessary to be DSO_TYPE_KERNEL or DSO_TYPE_GUEST_KERNEL. These two enums are for vmlinux. See thread [1]. We tried to fix this part but it is costy. Code machine__write_buildid_table() is another unfortunate function fall into this trap that, when issuing buildid event for a kernel module, cpumode it gives to the event is PERF_RECORD_MISC_USER, not PERF_RECORD_MISC_KERNEL. However, even with this bug, most of the time it doesn't causes real problem. I find this issue when trying to use a perf before commit 3d39ac5 ("perf machine: No need to have two DSOs lists") to parse a perf.data generated by newest perf. [1] https://lkml.org/lkml/2015/9/21/908 Signed-off-by: Wang Nan <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Li Zefan <[email protected]> Cc: Masami Hiramatsu <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 14a05e1 commit fd786fa

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tools/perf/util/build-id.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ static int machine__write_buildid_table(struct machine *machine, int fd)
211211
dsos__for_each_with_build_id(pos, &machine->dsos.head) {
212212
const char *name;
213213
size_t name_len;
214+
bool in_kernel = false;
214215

215216
if (!pos->hit)
216217
continue;
@@ -227,8 +228,11 @@ static int machine__write_buildid_table(struct machine *machine, int fd)
227228
name_len = pos->long_name_len + 1;
228229
}
229230

231+
in_kernel = pos->kernel ||
232+
is_kernel_module(name,
233+
PERF_RECORD_MISC_CPUMODE_UNKNOWN);
230234
err = write_buildid(name, name_len, pos->build_id, machine->pid,
231-
pos->kernel ? kmisc : umisc, fd);
235+
in_kernel ? kmisc : umisc, fd);
232236
if (err)
233237
break;
234238
}

0 commit comments

Comments
 (0)