Out of the box the Linux Kernel from Raspberry Pi OS does not come with activated support for Huge Pages, but it can be activated while compiling your own Linux Kernel.
Instructions on how to compile the Linux Kernel for Raspberry Pi can be mostly found on this website:
https://www.raspberrypi.com/documentation/computers/linux_kernel.html
Huge Pages can improve the speed of crypto mining (like Monero) hashes by about 50% compared to the stock Kernel.
First install some reqirements for building and download the Kernel sources:
sudo su
apt update
apt install -y git bc bison flex libssl-dev make libncurses5-dev
cd /opt
git clone --depth=1 https://github.com/raspberrypi/linux
cd linux
After that you need to configure the Kernel for Raspberry Pi 5:
make bcm2712_defconfig
Now you need to activate Huge Pages supprt:
make menuconfig
First change the kernel name by navigating to General Setup
and look for Local Version
. Change it to something like v8-16k-huge
. Then press ESC two times to go back.
At last go to File systems
, then to Pseudo filesystems
(at the bottom of the list) and there activate HugeTLB file system support
- Then press ESC two times to go back.
Then save the configuration.
From here, the normal compile steps have to be executed, which should take about an hour:
make -j4 Image.gz modules dtbs
make modules_install
cp arch/arm64/boot/dts/broadcom/*.dtb /boot/firmware/
cp arch/arm64/boot/dts/overlays/*.dtb* /boot/firmware/overlays/
cp arch/arm64/boot/dts/overlays/README /boot/firmware/overlays/
cp arch/arm64/boot/Image.gz /boot/firmware/kernel8-huge.img
Now activate the new Kernel:
echo "kernel=kernel8-huge.img" | tee -a /boot/firmware/config.txt
To have a specific Huge Page configuration, you have to edit the file /boot/firmware/cmdline.txt
in order for the Kernel to reserve the memory. Add something like this at the end of the line:
default_hugepagesz=2M hugepages=1280 hugepagesz=1G hugepages=3
Then reboot
At time of writing, the Rasperry Kernel was 6.1.x, later rechecked for 6.6.22 (still works for me).
EDIT: updated some file locations, thanks to @Pi-novice for pointing out, I probably mixed things up with my Pi 4 setup
For reference: on my newly arrived Raspberry Pi 5 with 8GB RAM the hashing rate is about 330 H/s with a single thread running XMRIG