Building and Managing Power Analysis Driver

Note

Power analysis is provided by the VTune Amplifier for Systems only. To analyze applications on Linux* target systems, run the CPU Sleep States or CPU Frequency analysis types from the VTune Amplifier GUI or CLI installed on the Linux or Windows* host. To analyze applications on Android* devices, use the Intel Energy Profiler (SoCWatch/WuWatch) to run the analysis directly on the device. You can view collected data either in the text-only mode on the device or import and view the data in the VTune Amplifier GUI nstalled on the host system.

Intel® VTune™ Amplifier uses the kernel driver to enable the power analysis. The power analysis driver is typically installed by default during the product installation. If the kernel on your Linux* system is not one of the supported kernels listed in the Release Notes, you need to build and load the driver manually as follows:

  1. Configure the basic software environment.

  2. Configure the kernel development environment.

  3. Build and (re)load the power analysis driver.

Configuring the Basic Software Environment

To compile the power analysis driver, the target system must have the following software installed:

  • C compiler that was used to build the kernel and that is capable of compiling programs with anonymous structs/unions, for example, GCC* 2.96 or later.

  • Tools needed to build a C-based program, for example, GNU* make tool, native assembler, linker.

  • System headers, for example, /usr/include/.

In addition, the kernel version must be 2.6.32 or later and must be configured with the following options enabled:

  • CONFIG_MODULES=y
  • CONFIG_MODULE_UNLOAD=y
  • CONFIG_TRACEPOINTS=y
  • CONFIG_FRAME_POINTER=y
  • CONFIG_COMPAT=y
  • CONFIG_TIMER_STATS=y

Note

You can verify these options by checking the kernel config file (for example, /boot/config, /proc/config.gz, /usr/src/linux/.config). Normally, these tools are installed, and kernel options are enabled, by default. However, administrators may remove/disable them from deployment systems, such as servers or embedded systems.

Configuring the Kernel Development Environment

  • Linux distributions based on kernel 2.6 * Red Hat Enterprise* Linux 6: Install the kernel-*-devel-*.rpm that is appropriate for the running kernel (on the third install CD)

  • Red Hat Fedora* Core 12 and later: Download and install the kernel-*-devel-*.rpm that is appropriate for the running kernel from http://download.fedora.redhat.com/pub/fedora/linux/ or by using YUM:

    $ yum install kernel-devel

  • Novell* SuSE Linux Enterprise Server* 10, 11 and Novell OpenSuSE*11.x: Install the kernel-source-*-`uname -m`.rpm that is appropriate for the running kernel

  • Red Flag* 5.x: Install the kernel-*-devel-*.rpm that is appropriate for the running kernel (on second install CD)

  • Debian* 5.x and Ubuntu* 10.x: Install the GCC and kernel development environment via:

    $ apt-get update

    $ apt-get install build-essential

    $ apt-get install linux-headers-`uname -r` 4

For kernels or Linux distributions not mentioned above, you need to set up the kernel build environment manually. This involves configuring the kernel sources (and hence kernel headers) to match the running kernel on the target system. For 2.6-based kernels, the kernel sources can be configured as follows:

# boot into the kernel you wish to build driver for 
# and make sure the kernel source tree is placed in 
#/usr/src/linux-`uname -r` 
# 
cd /usr/src/linux-`uname -r` 
vi Makefile # set EXTRAVERSION to a value corresponding to `uname -r`
make mrproper 
cp /boot/config-`uname -r` .config 
make oldconfig
make prepare 
make scripts 

Once the configuration completes, make sure that UTS_RELEASE in /usr/src/linux-`uname -r`/include/linux/version.h or in /usr/src/linux-`uname -r`/include/linux/utsrelease.h matches `uname -r`.

Building and (Re)Loading the Driver

Once the standard development tools and proper kernel development environment are installed, you can build and load the driver:

Note

To perform these steps, make sure you have root or sudo permissions.

 
# build the driver: 
cd /path/to/powerdk/src/ 
./build-driver 

# unload previously loaded driver from the kernel (if any): 
cd /path/to/powerdk/src/ 
./rmmod-apwr2 

# load the driver into the kernel: 
cd /path/to/powerdk/src/ 
sudo ./insmod-apwr2 

# autoload the driver at boot time: 
cd /path/to/powerdk/src/ 
./boot-script -g users -d /path/to/pre-built-drivers

If any errors occur during the building or loading of the driver, this may indicate a mismatch between the kernel sources and the running kernel. For load issues, check the /var/log/messages file or the output of dmesg.

For more complete information about compiler optimizations, see our Optimization Notice.