Kernel FDO User Guide

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 23.09

Hardware Requirements

  • Architecture: AArch64 or x86_64

Software Installation

Downloading the Kernel Source Code

Download the kernel source code, A-FOT, and dependency packages.

shell
yum install -y kernel-source A-FOT make gcc flex bison elfutils-libelf-devel diffutils openssl-devel dwarves

Copy the kernel source code.

shell
cp -r /usr/src/linux-6.4.0-8.0.0.16.oe2309.aarch64 .

Note: Change the version number as required.

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 arc (GCOV, using only the arc profile) or all (full PGO, using the arc and value profiles).all
4pgo_phaseFDO execution phase. The value can be 1 (kernel instrumentation phase) or 2 (data collection and kernel optimization 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
10-sSilent mode. The tool automatically reboots and switches the kernel to execute the second phase.None
11-nThe tool is not used to compile the kernel. This option applies to the scenario where the execution environment and kernel compilation environment are different.None

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).

Note: All paths must be absolute paths.

Note: The kernel of openEuler 23.09 does not support full PGO. Change the value of pgo_mode to arc.

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 kernel of openEuler 23.09 does not support full PGO. Change the value of pgo_mode to arc.