The Kali kernel is built in a “one size fits all” philosophy, to be able to support the largest base of hardware possible.
1. Install a performance measurement tool like likwid and fire off a quick likwid-bench benchmark.
2. Install graysky2's “Kernel GCC patch” to optimize your kernel for your exact CPU model.
3. Recompile this kernel once you have added the patch and selected your CPU model type.
1. Install likwid, fire off a benchmark:
|
apt-get install likwid likwid-topology -g | head # to find out which processor you have likwid-bench -t copy -w S0:100kB:1 # to run a quick benchmark on socket 0 |
2. The kernel CPU optimization patch can be found here. Install the dependencies required to perform a kernel recompile. Note that your version numbers may differ:
|
apt install build-essential libncurses5-dev fakeroot apt-cache search ^linux-source # search for the current linux-source package version apt install linux-source-4.9 # grab it ls /usr/src # which gets extracted to /usr/src |
3. Extract the kernel sources, and copy over the current config file.
|
mkdir ~/kernel; cd ~/kernel tar -xaf /usr/src/linux-source-4.9.tar.xz cp /boot/config-4.9.0-kali3-amd64 ~/kernel/linux-source-4.9/.config # Copy existing config |
Run menuconfig on your unpatched kernel config:
|
cd linux-source-4.9 make menuconfig |
Go to the following location in the kernel config and check out your options:
|
Processor type and features ---> Processor family (Generic-x86-64) ---> |
Exit the config without saving. Download the optimization patch, and patch the kernel:
|
cd ~/kernel wget https://raw.githubusercontent.com/graysky2/kernel_gcc_patch/master/enable_additional_cpu_optimizations_for_gcc_v4.9%2B_kernel_v3.15%2B.patch cd linux-source-4.9/ patch -p1 < ../enable_additional_cpu_optimizations_for_gcc_v4.9+_kernel_v3.15+.patch make menuconfig |
Once again visit the CPU model kernel config options. You should see new options:
|
Processor type and features ---> Processor family (Generic-x86-64) ---> |
Choose the relevant CPU type, save and exit the config. Now build your kernel.
|
export CONCURRENCY_LEVEL=5 #number of CPUs you have +1 make deb-pkg LOCALVERSION=-custom KDEB_PKGVERSION=$(make kernelversion)-1 |
Fire off another benchmark:
|
likwid-topology -g | head # to find out which processor you have likwid-bench -t copy -w S0:100kB:1 # to run a quick benchmark on socket 0 |
Did your benchmarks improve? Perhaps you can relate:
