/ website / blog

disable mitigations on ubuntu

May 24, 2020

By default, most Linux distributions will now enable kernel level mitigations for CPU bugs such as the infamous meltdown and spectre. These mitigations are extremely important for the use of running untrusted code (e.g. cloud VMs), but are less relevant for personal computers, who generally control what is being executed.

The mitigations will impact performance, especially for workloads that incur context switching. In particular, developers are highly impacted, since our build tools are all reading and writing files to/from disk, for tasks from compilation to code auto-completion. There is room for noticeable performance improvement by disabling mitigations.

Beware of the implications, and disable mitigations at your own risk.

step 1)

edit the /etc/default/grub file to include the mitigations=off linux boot parameter.

$ cat /etc/default/grub | grep GRUB_CMDLINE_LINUX_DEFAULT
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash mitigations=off"

step 2)

apply the changes to grub by running update grub

$ sudo update-grub
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.4.0-31-generic
Found initrd image: /boot/initrd.img-5.4.0-31-generic
Found linux image: /boot/vmlinuz-5.4.0-26-generic
Found initrd image: /boot/initrd.img-5.4.0-26-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
done

step 3)

reboot to pickup the changes

$ sudo reboot

step 4)

a quick grep on dmesg to see the kernel parameter got set

$ dmesg | grep 'BOOT_IMAGE'
[    0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-5.4.0-31-generic root=UUID=f0852c92-2b33-4bea-a689-dc519810d080 ro quiet splash mitigations=off vt.handoff=7
[    0.078788] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-5.4.0-31-generic root=UUID=f0852c92-2b33-4bea-a689-dc519810d080 ro quiet splash mitigations=off vt.handoff=7

gl;hf!

➡️ related posts in the tweaks series ...