Search code examples
linuxlinux-kernelprofilingperf

Perf: kernel module symbols not showing up in profiling


On loading and running a kernel module and then profiling through perf.

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

my kernel module's symbols are not present in the perf's report. Although the symbols are present in /proc/kallsyms. Also the module is not present in perf buildid-list As this answer says to make the module a kernel module, I tried but didn't help. What are the possible reasons that could lead to this?


Solution

  • The message Failed to open [thrUserCtrl], continuing without symbols sounds like perf was unable to find your module. Try installing it into

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

    directory as said in 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
    

    (don't forget depmod -a command after changing files in /lib/modules)

    This message is generated in map__load: http://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;
    

    when dso__load function returns error.