Intel® VTune™ Profiler

User Guide

ID 766319
Date 3/22/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

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 available for your Linux system version.

  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 the VTune Profiler to resolve kernel symbols and view kernel functions and kernel stacks but do not enable the assembly analysis.

Download and Install Available Debug Kernel Versions

After installing the Linux operating system, the kernel is contained in vmlinux, or vmlinuz, or bzImage in /boot. Linux vendors typically release compressed kernel files stripped of symbols (vmlinuz or bzImage). vmlinux is the uncompressed Linux kernel, but it does not include debug information. So, by default the VTune Profiler cannot retrieve kernel function information from these kernels and presents all hot addresses captured in the kernel as a unique function or module named [vmlinux]. However, some vendors have released special debug versions of their kernels that are suitable for performance analysis.

  1. Use the uname -r command to identify the running Linux kernel version.

  2. Download and install two RPMs matching your system: kernel-debug-debuginfo-*.rpm and kernel-debuginfo-common-*.rpm. To do this, use any of the following options:

    • Browse through the RPMs on your installation CDs or DVDs. For example, for SuSE Linux Enterprise* 9, 10, and 11 distros, SuSE provides "debug" kernel RPMs (kernel-debug-*.rpm) available on the install CD or from the website. After installing the RPM, the debug version of the kernel file is located under /boot/vmlinux-*-debug or under /boot/vmlinuz-*-debug. You need to manually uncompress this kernel file using the gunzip program.

    • Browse through the OS vendor FTP site and download the packages. For example: look at ftp://ftp.redhat.com/pub/redhat/linux/enterprise/5Server/en/os to get packages for Redhat* Enterprise Server.

    • Look for other sources on the internet. For example, for Red Hat Enterprise* Linux 3, 4 and 5 distros, Red Hat provides debuginfo RPMs at http://people.redhat.com/duffy/debuginfo/. After installing the RPM, the debug version of the kernel file is located under /usr/lib/debug/boot (EL 3) or /usr/lib/debug/lib/modules (EL 4, 5).

  3. Use the following commands to install the RPMs:

    rpm -ivh kernel-debuginfo-common-*.rpm
    rpm -ivh kernel-debug-debuginfo-*.rpm

    For some operating systems, you can use yum to install packages directly, for example:

    yum --enablerepo=rhel-debuginfo install kernel-debuginfo
  4. Verify that the packages have been installed, for example:

    rpm -qa|grep kernel
  5. Modify the VTune Profiler target properties and specify the path to the uncompressed kernel binary in the Dialog Box: Binary/Symbol Search , for example: /usr/lib/debug/lib/modules/2.6.18-128.el5debug/.

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.