Community support for Analyzers (Intel VTune™ Profiler, Intel Advisor, Intel Inspector)
The Intel sign-in experience has changed to support enhanced security controls. If you sign in, click here for more information.
4821 Discussions

Kernel module/driver profiling in Linux

I am using vtune 2011 to find out the CPU cycle consumed by my network driver (intel e1000) in Linux where I have only command line of vtune 2011 (no GUI). So far I can get the CPU cycles consumed by each function of the driver, but I need more details , I need the CPU cycles consumed by each line of code or at least the code execution flow. I also has another Kernel module running only in the kernel space and I would like to find out the CPU cycles consumed by each function inside this module.
Do you any tutorial which can help me here ? How to make vtune read or detect the code of my kernel module or the network driver ???
for kernel module currenly I am just getting the name of it with the number of CPU cycle consumed , no other function-level details ? please remember I have only vtune command line in my machine ....
Thank you
0 Kudos
4 Replies
Black Belt
Where you have available precise events, those are intended to correlate directly with the responsible instruction, but you would still need to look in the asm view to verify the association. In most cases, you are using non-precise events, where the counters tend to pile up on a subsequent instruction which is stalled pending availability of operands, and it's up to you to make the inference, preferably using source code built with -g so the asm view is tagged by source code line, and VTune can show you the flow.
There is no CPU cycles in report directly for associated functions, source lines and assembly lines. What you saw performance dataare *samples* of CPU_CLK_UNHALTED.THREAD event, that means, Cycle for specific source line should be approximated as:samples * (SAV value). For example, you got 80 samples in source line,and SAV value = 2,000,000, actualcycles >= 80 * 2,000,000, because code was executed butevent counter register(SAV value set) was not decreased to zero (interruption occurred) - for example, counter register data is0..2000000.

So actual cycles forline>=samples * SAV_value, but < (samples+1) * SAV_value.

You have to use "-g"option to build your code, sodebugging symbols and source line info will be generated.

For displaying performance dataofsome functionson kernel module, please refer to this article.

Regards, Peter

Thank you for your replay. My problem is how to tell vtune where the source file of my network driver is. I built the driver with -g as you suggested but I still can not see the source code using vtune. I collect the results in one machine where I don't have GUI and copy them to another machine where I have vtune GUI. All I can get now is the assmbly code of my driver inside Vtune GUI. Is there anyway to tell vtune where to find the source code of my driver after I copy and open the results in my other machine or even before that in the other machine????
Valued Contributor II

Given your circumstances, I would try collecting and doing symbol mapping on the non-GUI machine (a process in the helps called "finalization") and then try migrating that project result to the machine that can run the GUI. You'll probably need to have a lot of the same files in the same places and VTune Amplifier, in an attempt to avoid displaying invalidated data, can be persnickety regarding file time stamps: be sure the objects and symbols are newer than the sources. I've never tried expanding to source for a driverbut there should be a way to do it. Use the command line switch "-search-dir" to identify the location of the driver symbols and source during the amplxe-cl collection run, and then try copying the result directory produced by thatto the GUI-capable machine (whichhas the same source and symbol-loadedbinaries in the same places) and open the result file there. Not having tried it, I can't guarantee this will work, but it should have the best chance of working in the environment you describe.