性能:内核模块符号未显示在分析中

Perf: kernel module symbols not showing up in profiling

加载和 运行 一个内核模块,然后通过性能分析。

$perf record -a -g --call-graph dwarf sleep 30' $perf report

我的内核模块的符号没有出现在性能报告中。 虽然符号出现在 /proc/kallsyms. perf buildid-list 中也不存在该模块 正如 this 回答所说要使模块成为内核模块,我试过了但没有帮助。 可能导致这种情况的原因是什么?

消息 Failed to open [thrUserCtrl], continuing without symbols 听起来像是 perf 无法找到您的模块。尝试将其安装到

/lib/modules/`uname -r`/extra

https://wiki.centos.org/HowTos/BuildingKernelModules中所述的目录:

6. In this example, the file cifs.ko has just been created. 
 As root, copy the .ko file to the /lib/modules/<kernel-version>/extra/
 directory.
   [root@host linux-2.6.18.i686]# cp fs/cifs/cifs.ko /lib/modules/`uname -r`/extra

(在 /lib/modules 中更改文件后不要忘记 depmod -a 命令)

此消息生成于 map__loadhttp://elixir.free-electrons.com/linux/v4.11/source/tools/perf/util/map.c#L284

int map__load(struct map *map)
{
    const char *name = map->dso->long_name;
    int nr;
    ...
    nr = dso__load(map->dso, map);
    if (nr < 0) {
        if (map->dso->has_build_id) {
         ...
        } else
            pr_warning("Failed to open %s", name);

        pr_warning(", continuing without symbols\n");
        return -1;

dso__load函数returns错误。