Intel® VTune™ Profiler

User Guide

ID 766319
Date 6/24/2024
Public
Document Table of Contents

Enable Linux* Kernel Analysis

For successful performance analysis of the kernel and system libraries, do the following:

  1. Enable kernel modules resolution.

  2. Download and install debug info packages (if necessary)

  3. Build the Linux kernel with debug information.

Enable Kernel Modules Resolution

To provide accurate performance statistics for the Linux kernel, the VTune Profiler requires kernel modules information provided in the /proc/kallsyms file. Make sure the /proc/sys/kernel/kptr_restrict file contains values that enable reading /proc/kallsyms and providing non-zero addresses for the kernel pointers:

  • If the kptr_restrict value is 0, kernel addresses are provided without limitations (recommended).

  • If the kptr_restict value is 1, addresses are provided if the current user has a CAP_SYSLOG capability.

  • If the kptr_restrict value is 2, the kernel addresses are hidden regardless of privileges the current user has.

See more details at: http://lwn.net/Articles/420403/, http://man7.org/linux/man-pages/man7/capabilities.7.html.

If kernel pointers information was explicitly hidden by setting the kptr_restrict to a non-zero value, hardware event-based analysis results may not contain functions from kernel modules. As a result, you may see the CPU time associated with the [Outside any known module] item. To workaround this problem for the current session, set the contents of the /proc/sys/kernel/kptr_restrict file to 0 before starting the VTune Profiler as follows:

sysctl -w kernel.kptr_restrict=0
NOTE:

To enable kernel profiling without the Intel Sampling Driver via perf, set the perf_event_paranoid value to <= 1. See the Linux kernel documentation for details.

To resolve symbols for the Linux kernel, the VTune Profiler also uses the System.map file created during the kernel build and shipped with the system by default. If the file is located in a non-default directory, you may add it to the list of search directories in the Binary/Symbol Search dialog box when configuring your target properties.

NOTE:

The settings in the /proc/kallsyms and System.map file enable VTune Profiler to resolve kernel symbols and view kernel functions and kernel stacks but do not enable the assembly analysis.

Also, on modern distributives, only the root user can access System.map. Change permissions to make this file available for VTune Profiler.

Download and Install Available Debug Kernel Versions (if necessary)

You only need to install kernel debug information if you want to drill down into a kernel in the assembler/source pane. For example, you may want to do this to see hot spots inside a kernel function.

To install kernel debug symbol packages, see these resources:

For all other distributions, refer to the documentation in your distribution to install kernel debug symbols.

Build the Linux Kernel with Debug Information

  1. Configure the kernel sources.

  2. Edit the kernel source top-level Makefile and add the -g option to the following variables:

    CFLAGS_KERNEL := -g

    CFLAGS := -g

  3. Run make clean; make to create the vmlinux kernel file with debug information. Once a debug version of the kernel is created or obtained, specify that kernel file as the one to use during performance analysis.

As soon as the debug information is available for your kernel modules, any future analysis runs will display the kernel functions appropriately. To resolve the previously collected data against this new symbol information, update the project Search Directories and click the Re-resolve button to apply the changes.