OS Configuration

This section describes how to optimize the page size of the Linux kernel on the OpenEuler OS.

Principle

A page table serves as the fundamental memory allocation structure in the OS. Arm64 supports page table sizes of 4 KB, 16 KB, and 64 KB. The current page table size can only be statically configured and cannot be dynamically changed. The page table size is closely related to the server performance. In inference scenarios, the page table size can be changed according to different service requirements, which can bring about considerable performance benefits.

Optimization Configuration

This section uses openEuler 22.03 LTS SP4 installed on the Atlas 900 Pod A2 as an example to describe how to perform tuning.

openEuler 22.03 LTS SP4 uses a 4 KB page table by default. Change the page table size to 64 KB and test the inference performance of common NLP models before and after the size change.

Run the following command to query the size of the Linux kernel page table:

getconf PAGESIZE

You can change the size of the Linux kernel page table in either of the following ways:

Method 1: Download the 64 KB kernel installation package provided by the official website and run the following command to install it:
rpm -ivh --nodeps --force *.rpm 

Method 2: Perform compilation and installation using the source code.

  1. Install the required dependencies.
    yum install -y ncurses-devel bc openssl-devel rpm-build bison flex rsync dwarves elfutils-libelf-devel 
  2. Obtain the kernel source code.
    yum -y install kernel-source 

    The downloaded kernel source code is saved in the /usr/src directory.

  3. Compile the kernel.
    1. Run the following command to open the .config file:
      cd /usr/src/linux-5.10.0-254.0.0.158.oe2203sp4.aarch64
      vim .config

      In the .config file, change the value of CONFIG_LOCALVERSION to 64k. This parameter is used to display the new kernel version number. This is to distinguish the default kernel from the kernel of 64 KB.

    2. Apply the configuration file and modify the kernel parameters.
      make menuconfig
    3. On the GUI, choose Kernel Features > Page Size, set Page Size to 64KB, save the settings, and exit.

    4. Perform the compilation.
      make rpm-pkg -j 

      After the compilation is complete, the generated kernel RPM installation package is saved in the /root/rpmbuild/RPMS/aarch64 directory.

  4. Install the kernel package.
    cd /root/rpmbuild/RPMS/aarch64
    rpm -ivh --nodeps --force *.rpm 
  5. Restart the server.
    reboot 
  6. After the restart, check the kernel and page size.
    uname -a

    The result shows that the page size has been changed to 64 KB.

Performance Test Result

The test models are from MindSpeed LLM. For details, see the official website.

Table 1 Experiment data

os

Model

Experiment No.

Inference Duration (s)

Page Size: 4 KB

Inference Duration (s)

Page Size: 64 KB

Performance Improvement (%)

openEuler 22.03 SP4

llama2_7b

Experiment 1

15.49

13.83

10.7166

Experiment 2

16.02

14.18

11.4856

Experiment 3

15.73

13.99

11.0617

Average value

15.75

14

11.0923

deepseek_r1

Experiment 1

10.91

9.79

10.2658

Experiment 2

11.03

9.79

11.2421

Experiment 3

10.99

9.36

14.8317

Average value

10.98

9.65

12.1166