我要评分
获取效率
正确性
完整性
易理解

How to Change the Memory Page Size from 64 KB to 4 KB on openEuler

The default page size of openEuler 20.03 series OSs (kernel version 4.19) is 64 KB. You can check the page size by running the getconf PAGESIZE command, and change the value based on service requirements. The modification method is as follows:

  1. Check the current memory page size.
    getconf PAGESIZE

    If 65536 is displayed in the command output, the page size is 64 KB.

  2. Obtain the kernel source code.
    1. Create a directory and access the directory.
      mkdir -p /home/kernel-bcache
      cd /home/kernel-bcache
    2. Download the kernel source package to the /home/kernel-bcache directory.

    3. Decompress the source package.
      rpm2cpio kernel-4.19.90-2109.1.0.0108.oe1.src.rpm | cpio -divm
      tar -zxvf kernel.tar.gz
    4. Configure an image repository.
      1. Download openEuler-20.03-LTS-SP1-everything-aarch64-dvd.iso.
      2. Use an SFTP tool to upload the openEuler-20.03-LTS-SP1-everything-aarch64-dvd.iso file to the /root directory on the server.
      3. Create a local directory to mount the image.
        mkdir -p /iso
      4. Mount the ISO file to the local directory.
        mount /root/openEuler-20.03-LTS-SP1-everything-aarch64-dvd.iso /iso
    5. Create a Yum repository for the image.
      1. Open the configuration file.
        vi /etc/yum.repos.d/openEuler.repo
      2. Press i to enter the insert mode and add the following content to the file:
        [Base]
        name=Base
        baseurl=file:///iso
        enabled=1
        gpgcheck=0
        priority=1
         
        [openEuler-source]
        name=openEuler-source
        baseurl=http://repo.openeuler.org/openEuler-20.03-LTS-SP1/source/
        enabled=1
        gpgcheck=1
        gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS-SP1/source/RPM-GPG-KEY-openEuler
         
        [openEuler-os]
        name=openEuler-os
        baseurl=http://repo.openeuler.org/openEuler-20.03-LTS-SP1/OS/aarch64/
        enabled=0
        gpgcheck=1
        gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS-SP1/OS/aarch64/RPM-GPG-KEY-openEuler
         
        [openEuler-everything]
        name=openEuler-everything
        baseurl=http://repo.openeuler.org/openEuler-20.03-LTS-SP1/everything/aarch64/
        enabled=0
        gpgcheck=1
        gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS-SP1/everything/aarch64/RPM-GPG-KEY-openEuler
         
        [openEuler-EPOL]
        name=openEuler-epol
        baseurl=http://repo.openeuler.org/openEuler-20.03-LTS-SP1/EPOL/aarch64/
        enabled=1
        gpgcheck=0
         
        [openEuler-update]
        name=openEuler-update
        baseurl=http://repo.openeuler.org/openEuler-20.03-LTS-SP1/update/aarch64/
        enabled=1
        gpgcheck=0
      3. Press Esc to exit the insert mode. Input :wq! and press Enter to save the file and exit.
    6. Install the dependencies.
      dnf -y install ncurses-devel bison m4 flex rpm-build rpmdevtools asciidoc audit-libs-devel binutils-devel elfutils-devel elfutils-libelf-devel gtk2-devel java-1.8.0-openjdk-devel xz-devel libbabeltrace-devel libunwind-devel newt-devel numactl-devel openssl-devel pciutils-devel perl-generators python3-devel python3-docutils xmlto zlib-devel createrepo genisoimage
  3. Modify the kernel configuration file.
    1
    2
    3
    cd /home/kernel-bcache/kernel
    cp arch/arm64/configs/openeuler_defconfig .config
    make menuconfig
    
  4. Change the kernel page size to 4 KB.
    1. Choose Kernel Features.

    2. Press Enter to access the next-level menu, and choose Page size (64KB).

    3. Press Enter to access the next-level menu, and press the space button to choose 4KB.

    4. Choose Exit twice to save and exit.

  5. Check whether the page size has been changed to 4 KB.
    vi .config

    If CONFIG_ARM64_4K_PAGES=y is displayed in the command output, the configuration is successful.

  6. Overwrite the default configuration file.
    cp .config arch/arm64/configs/openeuler_defconfig

    Type y.

  7. Generate the kernel RPM package.
    1. Install the dependencies.
      yum install -y ncurses-devel bc openssl-devel rpm-build bison flex
    2. Go to the source code root directory.
      cp /boot/config-$(uname -r) .
    3. Compile the RPM package.
      make binrpm-pkg -j48

      You are advised not to compile the kernel with all cores. For example, for a 64-core processor, run make binrpm-pkg -j48. For a 96-core processor, run make binrpm-pkg -j72. Do not perform other operations during the compilation to avoid suspension.

    4. View the generated kernel RPM package.
      ls /home/rpmbuild/RPMS/aarch64/

  8. Install the kernel.
    1. Upload the generated kernel RPM package to the /home/kernel-rpm directory on the server.
      mkdir -p /home/kernel-rpm
      cd /home/kernel-rpm
      dnf -y install kernel-4.19.90-1.aarch64.rpm
    2. Check the default kernel boot items.
      grub2-editenv list
      • If the default version is the newly installed kernel version, go to 8.d.
      • Otherwise, go to 8.c.
    3. Modify the default kernel boot items.
      cat /etc/grub2-efi.cfg  | grep openEuler

      In the preceding figure, openEuler (4.19.90) 20.03 (LTS-SP1) indicates the newly installed kernel version.

      grub2-set-default "openEuler (4.19.90) 20.03 (LTS-SP1)"
    4. Reboot the system.
      1
      reboot
      
  9. After the system is rebooted, run the getconf PAGESIZE command to check whether the page size is 4 KB.