The pf kernel is a fork of the Linux kernel containing several patches to help with desktop responsiveness. You can read more about it here at the official website: https://pf.natalenko.name/
In brief it contains these patches:
-ck patchset with MuQSS
The -ck patches are designed to increase responsiveness and interactivity on desktop systems. Multiple Queue Skiplist scheduler is a desktop orientated CPU scheduler, with extremely low latencies. A variant of the BFS Brainfuck CPU Scheduler.
BFQ I/O scheduler
BFQ (Budget Fair Queuing scheduler) is a proportional-share storage-I/O scheduler that also supports hierarchical scheduling with a cgroups interface.
graysky’s kernel GCC patch
Adds a kernel option for CPU type that will allow you to compile a kernel optimized to your CPU. There is also a native option which is not unlike using “-march=native” via CFLAGS.
Here’s how to get this kernel up and running on Slackware Linux;
At the time of writing, the latest patchset is 4.10-pf2, so you would want to download the 4.10 version of the Linux kernel.
Open up a root terminal, and place the downloaded archives into /usr/src on your system.
Decompress the Linux tarball;
# tar -xvf linux-4.10.tar.xz
Decompress the -pf patches using:
# xzcat patch-4.10-pf2.xz > linux-4.10/patch-4.10-pf2
Now head into the kernel source directory:
# cd linux-4.10
Apply the patchset to the kernel:
# patch -Np1 < patch-4.10-pf2
If everything went fine (no error messages) you can now start to configure the -pf kernel.
The first thing to do is get your kernel config and copy it to “.config” in the kernel source directory. If you do not have an existing config, you can copy Slackware’s generic kernel config from the /boot directory.
# cp /boot/config-generic-4.4.38 .config
The next step is to configure the kernel, i’d recommend using the ncurses display, as i feel it’s the easiest to use.
# make nconfig
Head to “Processor type and Features” and change the “Processor Family” to Native Optimizations.
This will enable the kernel to use CPU instructions optimized for your exact CPU model. Similar to the behaviour of “-march=native” when used with CFLAGS for compiling any other software. Be warned that this setting will mean that the kernel can only run on the exact CPU model it was compiled on. So if you plan to compile this kernel for another system, you may not want this option included in the patches. You can skip this if that is the case.
Enable the rest of the -pf features provided by the patch like so;
General Setup -> “MuQSS cpu scheduler” (set to “Y”)
Enable the block layer -> IO Schedulers -> “BFQ I/O scheduler” (set to “Y”)
If you want BFQ as the default IO scheduler:
Enable the block layer -> IO Schedulers -> “Default I/O scheduler” (set to “BFQ”)
If not, you can enable it per disk after booting into the new kernel, for example:
# echo bfq > /sys/block/sdX/queue/scheduler
Where X is the allocated letter for your disk that should use bfq. For example; if your root disk was allocated as /dev/sda, you would write sda here.
Once you’ve finished making any additional changes save the config, and exit the configuration menu, you can now build the kernel.
# make bzImage
This may take a while depending on your CPU. You can speed it up a little by adding “-jN”, where N is the number of “cpu cores”+1, so if you have a cpu with 4 cores you would run “make -j5 bzImage”.
When that’s finished, start building the kernel modules:
# make modules
Then install the kernel modules to the system:
# make modules_install
Copy the kernel image into your /boot directory:
# cat arch/$(uname -m)/boot/bzImage > /boot/vmlinuz-pf
Copy the System.map file:
# cp System.map /boot/System.map-pf
Then rebuild initrd, using the mkinitrd helper provided in /usr/share/mkinitrd:
# /usr/share/mkinitrd/mkinitrd_command_generator.sh -k 4.10.0-pf2
The output will suggest something similar to this:
# mkinitrd -c -k 4.10.0-pf2 -f ext4 -r /dev/sda1 -m usbhid:hid_generic:xhci-hcd:ext4 -u -o /boot/initrd.gz
However, we don’t want to overwrite Slackware’s “generic” initrd, so we have to modify the last part to write to /boot/initrd-pf.gz.
Simply, adjusting it like so:
# mkinitrd -c -k 4.10.0-pf2 -f ext4 -r /dev/sda1 -m usbhid:hid_generic:xhci-hcd:ext4 -u -o /boot/initrd-pf.gz
The final step is to add this kernel to the bootloader, so that we can actually boot into it.
Assuming your new kernel compiled successfully, you’ll want to add a section to LILO’s bootloader config.
Open up /etc/lilo.conf and insert a bootloader section for this new kernel:
image = /boot/vmlinuz-pf initrd = /boot/initrd-pf.gz root = /dev/sda1 label = "4.10.0-pf2" read-only
One thing to make sure of, is that “root” is set to the correct disk, depending on how you partitioned your system originally.
Hopefully everything went well, and you will see the kernel appended to the list of bootable options as “Added 4.10.0-pf2 + * ”
You should now be able to reboot the machine and boot into the new -pf kernel on Slackware Linux.
Additionally, you should also rebuild any out of kernel modules required for your system, such as the nVidia driver being one example. In the case of Slackware, assuming you are using the build scripts for Slackbuilds.org, You can build a kernel module for this kernel quite simply:
# KERNEL=4.10.0-pf2 ./nvidia-kernel.SlackBuild
That’s all there is to it!