Sharing some of the code tidbits, thank you @Karsten for the following suggested perf recipe to see if your TLB miss cost would merit changing kernel size:
# perf list | grep end_tlb
stall_backend_tlb
stall_frontend_tlb
With kernel support confirmed the pipeline stalls due to TLB misses can be measured:
# perf stat -e instructions,cycles,stall_frontend_tlb,stall_backend_tlb ./a.out
time for 12344321 * 100M nops: 3.7 s
Performance counter stats for './a.out':
12,648,071,049 instructions # 1.14 insn per cycle
11,109,161,102 cycles
1,482,795,078 stall_frontend_tlb
1,334,751 stall_backend_tlb
3.706937365 seconds time elapsed
3.629966000 seconds user
0.000995000 seconds sys
The ratio (stall_frontend_tlb + stall_backend_tlb)/cycles
is an upper bound for the time that could be saved by using larger memory pages.
I also share how to install and boot 64K kernels for RHEL, Oracle Linux, and Ubuntu (I’d love to share instructions for SLE too, but could not find a resource on it).
To use a kernel with 64KB pages on Red Hat Enterprise Linux 9:
-
Install the kernel-64k package: dnf –y install kernel-64k
-
To enable the 64K kernel to be booted by default at boot time:
k=$(echo /boot/vmlinuz*64k)
grubby --set-default=$k \
--update-kernel=$k \
--args="crashkernel=2G-:640M"
To boot a 64KB kernel on Ubuntu 22.04:
-
Install the arm64+largemem
ISO which contains the 64K kernel by default, or:
-
Install the linux-generic-64k
package, which will add a 64K kernel option to the boot menu with the command sudo apt install linux-generic-64k
-
You can set the 64K kernel as the default boot option by updating the grub2 boot menu with the command:
echo "GRUB_FLAVOUR_ORDER=generic-64k" | sudo tee /etc/default/grub.d/local-order.cfg
For 64KB pages on Oracle Linux:
-
Install the kernel-uek64k package:
sudo dnf install -y kernel-uek64k
-
Set the 64K kernel as the default at boot time:
sudo grubby --set-default=$(echo /boot/vmlinuz*64k)
-
After rebooting the system, you can verify that you are running the 64K kernel using getconf.
Finally, to confirm that you’re running a 64K kernel, you can run getconf PAGESIZE
:
$ getconf PAGESIZE
65536