Rebuild and Install Module i915 for GPU Analysis on Ubuntu*
Rebuild and Install Module i915 for GPU Analysis on Ubuntu*
To collect i915 ftrace events required to analyze the
GPU utilization, your Linux kernel should be properly configured. If the Intel® VTune™ Profiler cannot start an analysis and provides an error message:
Collection of GPU usage events cannot be enabled. i915 ftrace events are not available
. You need to rebuild and install the re-configured module i915. For example, for kernel 4.14 and higher, these settings should be enabled:
CONFIG_EXPERT=y
and
CONFIG_DRM_I915_LOW_LEVEL_TRACEPOINTS=y
.
If you update the kernel often, make sure to
build the special kernel for GPU analysis.
On Ubuntu* systems, if you update the kernel rarely, you can configure and rebuild only module i915 as follows:
Installing the kernel requires root permissions.
- Add source package repositories for your Ubuntu* version.For example, on Ubuntu Bionic Beaver* add:sudo add-apt-repository -s "deb http://ru.archive.ubuntu.com/ubuntu/ bionic main restricted"
- Install build dependencies:sudo apt -y build-dep linux linux-image-$(uname -r) sudo apt -y install libncurses-dev flex bison openssl libssl-dev dkms libelf-dev libudev-dev libpci-dev libiberty-dev autoconf
- Install kernel headers:sudo apt -y install linux-headers-$(uname -r)
- Create a folder for kernel source:mkdir -p /tmp/kernel cd !$
- Download kernel sources:apt -y source linux cd linux-*
- Configure the kernel modules:cp /usr/src/linux-headers-$(uname -r)/.config ./ cp /usr/src/linux-headers-$(uname -r)/Module.symvers ./
- Update the version in Makefile in the current directory.The version value should be the same as in theuname -rcommand output. For example, ifuname -rprints4.15.0-20-generic, the values in the Makefile must be:VERSION = 4PATCHLEVEL = 15SUBLEVEL = 0EXTRAVERSION = -20-genericUpdate the file, if required, and save it.
- Make sure the kernel version is set correctly in the Makefile:make kernelversionThe command output for the example above must be:4.15.0-20-generic
- Update the new.configfile, if required, and save it.Make sure the following settings in the file are enabled:CONFIG_EXPERT=yCONFIG_FTRACE=yCONFIG_DEBUG_FS=yCONFIG_DRM_I915_LOW_LEVEL_TRACEPOINTS=y
- Create a fullconfigfile for the kernel:make olddefconfig
- Build module i915:make -j$(getconf _NPROCESSORS_ONLN) modules_prepare make -j$(getconf _NPROCESSORS_ONLN) M=./drivers/gpu/drm/i915 modulesIf you get the following error:LD [M] drivers/gpu/drm/i915/i915.o ld: no input filesyou need to replace the following lines inscripts/Makefile.build:link_multi_deps = \ $(filter $(addprefix $(obj)/, \ $($(subst $(obj)/,,$(@:.o=-objs))) \ $($(subst $(obj)/,,$(@:.o=-y))) \ $($(subst $(obj)/,,$(@:.o=-m)))), $^)with the line:link_multi_deps = $(filter %.o,$^)See the patch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=69ea912fda74a673d330d23595385e5b73e3a2b9 for more information.
- Install the new module:sudo make M=./drivers/gpu/drm/i915 modules_install
- Make sure the folder with the new driver is present in/etc/depmod.d/*files, or just add it:echo "search extradrivers" | sudo tee /etc/depmod.d/00-extra.conf
- Updateinitramfs:sudo depmod sudo update-initramfs -u
- Reboot the machine:sudo reboot
- Make sure the new driver is loaded:modinfo i915 | grep filenameThe expected command output is the following:filename: /lib/modules/4.15.0-20-generic/extradrivers/gpu/drm/i915/i915.ko
To roll back the changes and load the original module i915:
- Remove the folder with new driver from/etc/depmod.d/*files:sudo rm /etc/depmod.d/00-extra.conf
- Updateinitramfs:sudo depmod sudo update-initramfs -u
- Reboot the machine:sudo reboot