Overview

The feedback-directed optimization (FDO) of the kernel allows users to build optimized kernels for different applications to improve the application performance in single-application scenarios. In addition, FDO is integrated GCC for openEuler, and A-FOT provides automatic optimization, enabling users to easily enable FDO.

Installation and Deployment

Software Requirements

  • OS: openEuler 22.03 LTS SP4

Hardware Requirements

  • Architecture: AArch64 or x86_64

Software Installation

Downloading the Kernel Source Code

shell
yum install -y kernel-source
cp -r /usr/src/linux-5.10.0-153.12.0.89.oe2203SP4.aarch64 .

Note: Change the version number as required.

(Optional) Installing GCC

GCC of openEuler 22.03 LTS SP4 can compile kernels with PGO. Alternatively, you can perform the following steps to manually build a customized GCC based on other GCC versions (GCC 10 or later). The key is to add --disable-tls --disable-libsanitizer during configuration.

shell
cd ${GCC_DIR}
mkdir build
cd build
../configure --prefix=${GCC_INSTALL_PREFIX} --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,fortran,lto --enable-plugin --enable-initfini-array --disable-libgcj --without-isl --without-cloog --enable-gnu-indirect-function --build=aarch64-linux-gnu --with-stage1-ldflags='-Wl,-z,relro,-z,now' --with-boot-ldflags='-Wl,-z,relro,-z,now' --disable-bootstrap --with-multilib-list=lp64 --enable-bolt --disable-tls --disable-libsanitizer
make -j 96 && make install -j 96

Installing A-FOT

shell
git clone https://atomgit.com/openeuler/A-FOT.git

Usage

You can use A-FOT to enable kernel FDO and obtain the optimized kernel by specifying opt_mode as Auto_kernel_PGO. Other configuration items can be specified on the CLI, for example, ./a-fot --pgo_phase 1. -s and -n options can be specified on CLI only. Options related to kernel FDO are as follows.

No.Option (Configuration File)DescriptionDefault Value
1config_filePath of the configuration file. User configurations are read from this file.${afot_path}/a-fot.ini
2opt_modeOptimization mode to be executed by the tool. The value can be AutoFDO, AutoPrefetch, AutoBOLT, or Auto_kernel_PGO.AutoPrefetch
3pgo_modeKernel FDO mode, which can be GCOV or full PGO.all
4pgo_phaseFDO execution phase.1
5kernel_srcKernel source code directory. If this option is not specified, the tool automatically downloads the source code.None (optional)
6kernel_nameFile name of the kernel build. The tool will add the -pgoing or -pgoed suffix depending on the phase.kernel
7work_pathScript working directory, which is used to store log files, wrappers, and profiles./opt (/tmp cannot be used.)
8run_scriptApplication execution script. The user needs to write the script, which will be used by the tool to execute the target application./root/run.sh
9gcc_pathGCC path./usr

After configuring the compilation options, run the following command to use A-FOT to automatically optimize the kernel:

shell
a-fot --config_file ./a-fot.ini -s

Note: The -s option instructs A-FOT to automatically reboot into the compiled kernel. If you do not want the tool to automatically perform this sensitive operation, omit this option. However, you need to manually reboot and perform the second phase (--pgo_phase 2).

Compatibility

This section describes the compatibility issues in some special scenarios. This project is in continuous iteration and issues will be fixed as soon as possible. Developers are welcome to join this project.

  • The implementation of FDO in the GCC varies with the version. Therefore, GCC 10 or later is required.