# SPDX-License-Identifier: GPL-2.0-only
menu "Profile Guided Optimization (PGO) (EXPERIMENTAL)"

config ARCH_SUPPORTS_PGO_CLANG
	bool

config PGO_CLANG
	bool "Enable clang's PGO-based kernel profiling"
	depends on PROC_FS
	depends on ARCH_SUPPORTS_PGO_CLANG
	depends on CC_IS_CLANG
	depends on !ARCH_WANTS_NO_INSTR || CC_HAS_NO_PROFILE_FN_ATTR
	help
	  This option enables clang's PGO (Profile Guided Optimization) based
	  code profiling to better optimize the kernel.

	  If unsure, say N.

	  Run a representative workload for your application on a kernel
	  compiled with this option and download the raw profile file from
	  /proc/pgo/vmlinux.profraw. This file needs to be
	  processed with llvm-profdata. It may be merged with other collected
	  raw profiles.

	  Copy the processed profile file into vmlinux.profdata, and enable
	  KCFLAGS=-fprofile-use=vmlinux.profdata to produce an optimized
	  kernel.

	  Note that a kernel compiled with profiling flags will be
	  significantly larger and run slower. Also be sure to exclude files
	  from profiling which are not linked to the kernel image to prevent
	  linker errors.

	  Note that the procfs filesystem has to be mounted to access
	  profiling data.

endmenu
