Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Profiling Linux Kernel Modules

I am interested in profiling a module for the Linux Kernel. I tried it this way:

  1. Built the kernel with CONFIG_PROFILING=y
  2. Booted the kernel with profile=2
  3. Reset the profiler by echo 123 > /proc/profile
  4. The module was successfully loaded by a dedicated daemon
  5. Run a user-space app that is using the module through specific ioctl calls. The test app worked as expected so the module was working OK.
  6. Read the profiling info using readprofile -p /proc/profile -m System.map where System.app was generated along with the kernel.

So far, so good. Almost everything worked as expected. What did not work however, is that I didn't get any info about my module, i.e. there was no mention of any function from the module.

However, on second thoughts, I remebered that I forgot to recompile the module using the CONFIG_PROFILING=y.

So, my question is: Did the module not show up in the profiling log because it had not been compiled with the CONFIG_PROFILING=y or is there some other more obvious reason that I don't know of?

If one wonders, why I am asking rather than trying it straight away, that is because, I can't do it at home and I'd rather like to hear what the knowledgable would say before I get access to the code again.

like image 525
Albus Dumbledore Avatar asked Apr 23 '11 08:04

Albus Dumbledore


1 Answers

It doesn't seem possible for modules to be profiled in this way as they are loaded dynamically, which means that they are missing from the System.map file.

A solution would be to build the driver into the kernel. Unfortunately, this does not always work as the system may be designed to run only with the driver built into a module.

like image 150
Albus Dumbledore Avatar answered Sep 22 '22 15:09

Albus Dumbledore