Slackware kernel (re)compilation

I needed to rebuild my kernel with NUMA support ( for VPP installation )

Stock Slackware kernel does not have NUMA built-in, let’s fix this !

No matter the option, the (re)built method is the same 😉

Kernel sources are installed in /usr/src/

:~ # ls /usr/src/ -lastrh
total 97M
 97M -rw-r--r--  1 root root  97M Jan  5 15:51 linux-4.14.12.tar.xz
4.0K drwxr-xr-x 22 root root 4.0K Jan 30 00:59 linux-4.14.12/
4.0K drwxr-xr-x 17 root root 4.0K Feb  4 00:12 ../
4.0K drwxr-xr-x 25 root root 4.0K Feb  4 02:26 linux-4.14.17/
   0 lrwxrwxrwx  1 root root   13 Feb  5 19:33 linux -> linux-4.14.17/
4.0K drwxr-xr-x  4 root root 4.0K Feb  5 19:33 ./
23:42 root@ws1:~ # 

Let’s save the stock kernel config file, not that I use the `linux` dir directly, as it’s a symlink to the latest linux-4.14.17 dir.

:~ # cp /usr/src/linux/.config /usr/src/linux/.config.stock

Get the running kernel config, (though I could have used the previous .config file ) . As a good habit, I always run `make oldconfig` to show if there is newer option . I doubt to find some new option here as I’m recompiling the running slackware kernel… but when compiling a new kernel version, new option can be added. You night want to check them out and set them as built-in/module/not set.

:~ # zcat /proc/config.gz > /usr/src/linux/.config
:~ # cd /usr/src/linux
:/usr/src/linux # 
:/usr/src/linux # 
:/usr/src/linux # make oldconfig
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/basic/bin2c
  HOSTCC  scripts/kconfig/conf.o
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/conf
scripts/kconfig/conf  --oldconfig Kconfig
#
# configuration written to .config
#
:/usr/src/linux #

Then modify options  with `make menuconfig` ( it’s a ncurses interface ).

  • General setup -> add as built-in Memory placement aware NUMA scheduler
  • Processor type and features -> add as built-in Numa Memory Allocation and Scheduler Support
  • Processor type and features -> add as built-in NUMA emulation
  • Also as explained in the official doc, if you rebuilt an already installed  kernel, in order to avoid messing up with kernel modules for that kernel, you need to change the LOCAL_VERSION under: General setup -> Local version ( I used a suffix -vpp )
:/usr/src/linux # make menuconfig
  HOSTCC  scripts/kconfig/mconf.o
  HOSTCC  scripts/kconfig/lxdialog/checklist.o
  HOSTCC  scripts/kconfig/lxdialog/util.o
  HOSTCC  scripts/kconfig/lxdialog/inputbox.o
  HOSTCC  scripts/kconfig/lxdialog/textbox.o
  HOSTCC  scripts/kconfig/lxdialog/yesno.o
  HOSTCC  scripts/kconfig/lxdialog/menubox.o
  HOSTLD  scripts/kconfig/mconf
scripts/kconfig/mconf  Kconfig
configuration written to .config

*** End of the configuration.
*** Execute 'make' to start the build or try 'make help'.

:/usr/src/linux #

Let’s make the kernel and modules

:/usr/src/linux # make all
 HOSTCC scripts/basic/fixdep
 CHK include/config/kernel.release
 CHK include/generated/uapi/linux/version.h
 HOSTCC scripts/basic/bin2c
 DESCEND objtool
 HOSTCC /usr/src/linux-4.14.17/tools/objtool/fixdep.o
<--- output suppressed--->
 LD [M] sound/usb/usx2y/snd-usb-us122l.ko
 LD [M] sound/usb/usx2y/snd-usb-usx2y.ko
 LD [M] sound/x86/snd-hdmi-lpe-audio.ko
 LD [M] virt/lib/irqbypass.ko
:/usr/src/linux #

then install the modules in /lib/modules

:/usr/src/linux # make modules_install
  INSTALL arch/x86/crypto/blowfish-x86_64.ko
  INSTALL arch/x86/crypto/camellia-aesni-avx-x86_64.ko
<--- output suppressed --->
 INSTALL sound/x86/snd-hdmi-lpe-audio.ko
  INSTALL virt/lib/irqbypass.ko
  DEPMOD  4.14.17-vpp
:/usr/src/linux #

Note that a 4.14.17-vpp directory has been created 😉 ( that means that is you have forgotten to modify LOCAL_VERSION, you are likely to overwrite actual kernel modules.

:~ # ls /lib/modules/
4.14.15/  4.14.17/  4.14.17-vpp/
:~ #

Let’s put the kernel in place, copying kernel/config/system.map file in /boot

:/usr/src/linux # cp arch/x86/boot/bzImage /boot/vmlinuz-vpp-4.14.17
:/usr/src/linux # cp .config /boot/.config-vpp-4.14.17
:/usr/src/linux # cp System.map /boot/System.map-vpp-4.14.17
:/usr/src/linux #
:/usr/src/linux # ls -lastr /boot/System.map
0 lrwxrwxrwx 1 root root 23 Feb  5 19:27 /boot/System.map -> System.map-huge-4.14.17
:/usr/src/linux # 
:/usr/src/linux # rm /boot/System.map
:/usr/src/linux # ln -s /boot/System.map-vpp-4.14.17 /boot/System.map
:/usr/src/linux #
:/usr/src/linux # ls -lastr /boot/System.map
0 lrwxrwxrwx 1 root root 28 Feb  6 20:03 /boot/System.map -> /boot/System.map-vpp-4.14.17
:/usr/src/linux #

Let’s create the initrd

:/usr/src/linux # /usr/share/mkinitrd/mkinitrd_command_generator.sh -k 4.14.17-vpp
#
# mkinitrd_command_generator.sh revision 1.45
#
# This script will now make a recommendation about the command to use
# in case you require an initrd image to boot a kernel that does not
# have support for your storage or root filesystem built in
# (such as the Slackware 'generic' kernels').
# A suitable 'mkinitrd' command will be:

mkinitrd -c -k 4.14.17-vpp -f ext4 -r /dev/sda1 -m xhci-pci:ohci-pci:ehci-pci:xhci-hcd:uhci-hcd:ehci-hcd:hid:usbhid:i2c-hid:hid_generic:hid-cherry:hid-logitech:hid-logitech-dj:hid-logitech-hidpp:hid-lenovo:hid-microsoft:hid_multitouch:jbd2:mbcache:ext4 -u -o /boot/initrd.gz

Please note that I’ve specified the -k option with kernel version set to 4.14.17-vpp instead of just 4.14.17. It’s because mkinitrd will look in the corresponding directory for kernel modules, ie in /lib/modules/$kernelVersion … here we want mkinitrd to look in /lib/modules/4.14.17-vpp/

:/usr/src/linux # mkinitrd -c -k 4.14.17-vpp -f ext4 -r /dev/sda1 -m xhci-pci:ohci-pci:ehci-pci:xhci-hcd:uhci-hcd:ehci-hcd:hid:usbhid:i2c-hid:hid_generic:hid-cherry:hid-logitech:hid-logitech-dj:hid-logitech-hidpp:hid-lenovo:hid-microsoft:hid_multitouch:jbd2:mbcache:ext4 -u -o /boot/initrd-4.14.17-vpp.gz
OK: /lib/modules/4.14.17-vpp/kernel/drivers/usb/host/xhci-hcd.ko added.
OK: /lib/modules/4.14.17-vpp/kernel/drivers/usb/host/xhci-pci.ko added.
<--- output suppressed --->
OK: /lib/modules/4.14.17-vpp/kernel/fs/mbcache.ko added.
OK: /lib/modules/4.14.17-vpp/kernel/fs/ext4/ext4.ko added.
49081 blocks
/boot/initrd-4.14.17-vpp.gz created.
Be sure to run lilo again if you use it.
:/usr/src/linux #

Let’s add the corresponding section in lilo.conf

image = /boot/vmlinuz-vpp-4.14.17                                                                                                         
  initrd = /boot/initrd-4.14.17-vpp.gz                                                                                                    
  root = /dev/sda1                                                                                                                        
  label = vpp-4.14.17                                                                                                                     
  read-only

And run LILO

:~ # lilo -v
LILO version 24.2 (released 22-November-2015)
<--- output suppressed --->

Boot image: /boot/vmlinuz-vpp-4.14.17
Mapping RAM disk /boot/initrd-4.14.17-vpp.gz
The initial RAM disk will be loaded in the high memory above 16M.
Added vpp-4.14.17  +

<--- output suppressed --->
Writing boot sector.
/boot/boot.0800 exists - no boot sector backup copy made.
:~ #

Then reload 🙂

 

Once it’s back running on our new kernel, let’s check NUMA support.

:~ # uname -a
Linux ws1.home.lodpp.net 4.14.17-vpp #2 SMP Tue Feb 6 09:15:33 CET 2018 x86_64 Intel(R) Xeon(R) CPU D-1540 @ 2.00GHz GenuineIntel GNU/Linux
:~ # zcat /proc/config.gz | grep -i numa
CONFIG_ARCH_SUPPORTS_NUMA_BALANCING=y
CONFIG_NUMA_BALANCING=y
CONFIG_NUMA_BALANCING_DEFAULT_ENABLED=y
CONFIG_NUMA=y
CONFIG_AMD_NUMA=y
CONFIG_X86_64_ACPI_NUMA=y
# CONFIG_NUMA_EMU is not set
CONFIG_USE_PERCPU_NUMA_NODE_ID=y
CONFIG_ACPI_NUMA=y
:~ # 

Source:

kernel install/compilation: https://docs.slackware.com/howtos:slackware_admin:kernelbuilding

System.map : http://rlworkman.net/system.map/

Leave a Reply

Your email address will not be published. Required fields are marked *