€•¡eŒsphinx.addnodes”Œdocument”“”)”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)”}”(hhh]”(hŒ pending_xref”“”)”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…””}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ%/translations/zh_CN/dev-tools/autofdo”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)”}”(hhh]”hŒChinese (Traditional)”…””}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ%/translations/zh_TW/dev-tools/autofdo”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ%/translations/it_IT/dev-tools/autofdo”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ%/translations/ja_JP/dev-tools/autofdo”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ%/translations/ko_KR/dev-tools/autofdo”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒPortuguese (Brazilian)”…””}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ%/translations/pt_BR/dev-tools/autofdo”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒSpanish”…””}”hh–sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ%/translations/sp_SP/dev-tools/autofdo”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒcomment”“”)”}”(hŒ SPDX-License-Identifier: GPL-2.0”h]”hŒ SPDX-License-Identifier: GPL-2.0”…””}”hh·sbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1hµhhh²hh³Œ?/var/lib/git/docbuild/linux/Documentation/dev-tools/autofdo.rst”h´KubhŒsection”“”)”}”(hhh]”(hŒtitle”“”)”}”(hŒ#Using AutoFDO with the Linux kernel”h]”hŒ#Using AutoFDO with the Linux kernel”…””}”(hhÏh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhhÊh²hh³hÇh´KubhŒ paragraph”“”)”}”(hX†This enables AutoFDO build support for the kernel when using the Clang compiler. AutoFDO (Auto-Feedback-Directed Optimization) is a type of profile-guided optimization (PGO) used to enhance the performance of binary executables. It gathers information about the frequency of execution of various code paths within a binary using hardware sampling. This data is then used to guide the compiler's optimization decisions, resulting in a more efficient binary. AutoFDO is a powerful optimization technique, and data indicates that it can significantly improve kernel performance. It's especially beneficial for workloads affected by front-end stalls.”h]”hXŠThis enables AutoFDO build support for the kernel when using the Clang compiler. AutoFDO (Auto-Feedback-Directed Optimization) is a type of profile-guided optimization (PGO) used to enhance the performance of binary executables. It gathers information about the frequency of execution of various code paths within a binary using hardware sampling. This data is then used to guide the compiler’s optimization decisions, resulting in a more efficient binary. AutoFDO is a powerful optimization technique, and data indicates that it can significantly improve kernel performance. It’s especially beneficial for workloads affected by front-end stalls.”…””}”(hhßh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´KhhÊh²hubhÞ)”}”(hXâFor AutoFDO builds, unlike non-FDO builds, the user must supply a profile. Acquiring an AutoFDO profile can be done in several ways. AutoFDO profiles are created by converting hardware sampling using the "perf" tool. It is crucial that the workload used to create these perf files is representative; they must exhibit runtime characteristics similar to the workloads that are intended to be optimized. Failure to do so will result in the compiler optimizing for the wrong objective.”h]”hXæFor AutoFDO builds, unlike non-FDO builds, the user must supply a profile. Acquiring an AutoFDO profile can be done in several ways. AutoFDO profiles are created by converting hardware sampling using the “perf†tool. It is crucial that the workload used to create these perf files is representative; they must exhibit runtime characteristics similar to the workloads that are intended to be optimized. Failure to do so will result in the compiler optimizing for the wrong objective.”…””}”(hhíh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´KhhÊh²hubhÞ)”}”(hXXThe AutoFDO profile often encapsulates the program's behavior. If the performance-critical codes are architecture-independent, the profile can be applied across platforms to achieve performance gains. For instance, using the profile generated on Intel architecture to build a kernel for AMD architecture can also yield performance improvements.”h]”hXZThe AutoFDO profile often encapsulates the program’s behavior. If the performance-critical codes are architecture-independent, the profile can be applied across platforms to achieve performance gains. For instance, using the profile generated on Intel architecture to build a kernel for AMD architecture can also yield performance improvements.”…””}”(hhûh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´KhhÊh²hubhÞ)”}”(hXBThere are two methods for acquiring a representative profile: (1) Sample real workloads using a production environment. (2) Generate the profile using a representative load test. When enabling the AutoFDO build configuration without providing an AutoFDO profile, the compiler only modifies the dwarf information in the kernel without impacting runtime performance. It's advisable to use a kernel binary built with the same AutoFDO configuration to collect the perf profile. While it's possible to use a kernel built with different options, it may result in inferior performance.”h]”hXFThere are two methods for acquiring a representative profile: (1) Sample real workloads using a production environment. (2) Generate the profile using a representative load test. When enabling the AutoFDO build configuration without providing an AutoFDO profile, the compiler only modifies the dwarf information in the kernel without impacting runtime performance. It’s advisable to use a kernel binary built with the same AutoFDO configuration to collect the perf profile. While it’s possible to use a kernel built with different options, it may result in inferior performance.”…””}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K!hhÊh²hubhÞ)”}”(hŒýOne can collect profiles using AutoFDO build for the previous kernel. AutoFDO employs relative line numbers to match the profiles, offering some tolerance for source changes. This mode is commonly used in a production environment for profile collection.”h]”hŒýOne can collect profiles using AutoFDO build for the previous kernel. AutoFDO employs relative line numbers to match the profiles, offering some tolerance for source changes. This mode is commonly used in a production environment for profile collection.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K+hhÊh²hubhÞ)”}”(hŒmIn a profile collection based on a load test, the AutoFDO collection process consists of the following steps:”h]”hŒmIn a profile collection based on a load test, the AutoFDO collection process consists of the following steps:”…””}”(hj%h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K0hhÊh²hubhŒenumerated_list”“”)”}”(hhh]”(hŒ list_item”“”)”}”(hŒKInitial build: The kernel is built with AutoFDO options without a profile. ”h]”hÞ)”}”(hŒJInitial build: The kernel is built with AutoFDO options without a profile.”h]”hŒJInitial build: The kernel is built with AutoFDO options without a profile.”…””}”(hj>h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K3hj:ubah}”(h]”h ]”h"]”h$]”h&]”uh1j8hj5h²hh³hÇh´Nubj9)”}”(hX Profiling: The above kernel is then run with a representative workload to gather execution frequency data. This data is collected using hardware sampling, via perf. AutoFDO is most effective on platforms supporting advanced PMU features like LBR on Intel machines. ”h]”hÞ)”}”(hXProfiling: The above kernel is then run with a representative workload to gather execution frequency data. This data is collected using hardware sampling, via perf. AutoFDO is most effective on platforms supporting advanced PMU features like LBR on Intel machines.”h]”hXProfiling: The above kernel is then run with a representative workload to gather execution frequency data. This data is collected using hardware sampling, via perf. AutoFDO is most effective on platforms supporting advanced PMU features like LBR on Intel machines.”…””}”(hjVh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K6hjRubah}”(h]”h ]”h"]”h$]”h&]”uh1j8hj5h²hh³hÇh´Nubj9)”}”(hŒdAutoFDO profile generation: Perf output file is converted to the AutoFDO profile via offline tools. ”h]”hÞ)”}”(hŒcAutoFDO profile generation: Perf output file is converted to the AutoFDO profile via offline tools.”h]”hŒcAutoFDO profile generation: Perf output file is converted to the AutoFDO profile via offline tools.”…””}”(hjnh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´Kh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´Kvhj:ubah}”(h]”h ]”h"]”h$]”h&]”uh1j8hj½h²hh³hÇh´Nubj9)”}”(hX’Run the load tests. The '-c' option in perf specifies the sample event period. We suggest using a suitable prime number, like 500009, for this purpose. - For Intel platforms:: $ perf record -e BR_INST_RETIRED.NEAR_TAKEN:k -a -N -b -c -o -- - For AMD platforms: The supported systems are: Zen3 with BRS, or Zen4 with amd_lbr_v2. To check, For Zen3:: $ cat /proc/cpuinfo | grep " brs" For Zen4:: $ cat /proc/cpuinfo | grep amd_lbr_v2 The following command generated the perf data file:: $ perf record --pfm-events RETIRED_TAKEN_BRANCH_INSTRUCTIONS:k -a -N -b -c -o -- ”h]”(hÞ)”}”(hŒ—Run the load tests. The '-c' option in perf specifies the sample event period. We suggest using a suitable prime number, like 500009, for this purpose.”h]”hŒ›Run the load tests. The ‘-c’ option in perf specifies the sample event period. We suggest using a suitable prime number, like 500009, for this purpose.”…””}”(hjVh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´KxhjRubjò)”}”(hhh]”(j9)”}”(hŒwFor Intel platforms:: $ perf record -e BR_INST_RETIRED.NEAR_TAKEN:k -a -N -b -c -o -- ”h]”(hÞ)”}”(hŒFor Intel platforms::”h]”hŒFor Intel platforms:”…””}”(hjkh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K|hjgubj»)”}”(hŒ^$ perf record -e BR_INST_RETIRED.NEAR_TAKEN:k -a -N -b -c -o -- ”h]”hŒ^$ perf record -e BR_INST_RETIRED.NEAR_TAKEN:k -a -N -b -c -o -- ”…””}”hjysbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jºh³hÇh´K~hjgubeh}”(h]”h ]”h"]”h$]”h&]”uh1j8hjdubj9)”}”(hXmFor AMD platforms: The supported systems are: Zen3 with BRS, or Zen4 with amd_lbr_v2. To check, For Zen3:: $ cat /proc/cpuinfo | grep " brs" For Zen4:: $ cat /proc/cpuinfo | grep amd_lbr_v2 The following command generated the perf data file:: $ perf record --pfm-events RETIRED_TAKEN_BRANCH_INSTRUCTIONS:k -a -N -b -c -o -- ”h]”(hÞ)”}”(hŒFor AMD platforms:”h]”hŒFor AMD platforms:”…””}”(hj‘h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K€hjubhÞ)”}”(hŒLThe supported systems are: Zen3 with BRS, or Zen4 with amd_lbr_v2. To check,”h]”hŒLThe supported systems are: Zen3 with BRS, or Zen4 with amd_lbr_v2. To check,”…””}”(hjŸh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K‚hjubhÞ)”}”(hŒ For Zen3::”h]”hŒ For Zen3:”…””}”(hj­h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K„hjubj»)”}”(hŒ!$ cat /proc/cpuinfo | grep " brs"”h]”hŒ!$ cat /proc/cpuinfo | grep " brs"”…””}”hj»sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jºh³hÇh´K†hjubhÞ)”}”(hŒ For Zen4::”h]”hŒ For Zen4:”…””}”(hjÉh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´Kˆhjubj»)”}”(hŒ%$ cat /proc/cpuinfo | grep amd_lbr_v2”h]”hŒ%$ cat /proc/cpuinfo | grep amd_lbr_v2”…””}”hj×sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jºh³hÇh´KŠhjubhÞ)”}”(hŒ4The following command generated the perf data file::”h]”hŒ3The following command generated the perf data file:”…””}”(hjåh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´KŒhjubj»)”}”(hŒo$ perf record --pfm-events RETIRED_TAKEN_BRANCH_INSTRUCTIONS:k -a -N -b -c -o -- ”h]”hŒo$ perf record --pfm-events RETIRED_TAKEN_BRANCH_INSTRUCTIONS:k -a -N -b -c -o -- ”…””}”hjósbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jºh³hÇh´KŽhjubeh}”(h]”h ]”h"]”h$]”h&]”uh1j8hjdubeh}”(h]”h ]”h"]”h$]”h&]”j”j•uh1jñh³hÇh´K|hjRubeh}”(h]”h ]”h"]”h$]”h&]”uh1j8hj½h²hh³Nh´Nubj9)”}”(hŒ;(Optional) Download the raw perf file to the host machine. ”h]”hÞ)”}”(hŒ:(Optional) Download the raw perf file to the host machine.”h]”hŒ:(Optional) Download the raw perf file to the host machine.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´Khjubah}”(h]”h ]”h"]”h$]”h&]”uh1j8hj½h²hh³hÇh´Nubj9)”}”(hXRTo generate an AutoFDO profile, two offline tools are available: create_llvm_prof and llvm_profgen. The create_llvm_prof tool is part of the AutoFDO project and can be found on GitHub (https://github.com/google/autofdo), version v0.30.1 or later. The llvm_profgen tool is included in the LLVM compiler itself. It's important to note that the version of llvm_profgen doesn't need to match the version of Clang. It needs to be the LLVM 19 release of Clang or later, or just from the LLVM trunk. :: $ llvm-profgen --kernel --binary= --perfdata= -o or :: $ create_llvm_prof --binary= --profile= --format=extbinary --out= Note that multiple AutoFDO profile files can be merged into one via:: $ llvm-profdata merge -o ... ”h]”(hÞ)”}”(hXïTo generate an AutoFDO profile, two offline tools are available: create_llvm_prof and llvm_profgen. The create_llvm_prof tool is part of the AutoFDO project and can be found on GitHub (https://github.com/google/autofdo), version v0.30.1 or later. The llvm_profgen tool is included in the LLVM compiler itself. It's important to note that the version of llvm_profgen doesn't need to match the version of Clang. It needs to be the LLVM 19 release of Clang or later, or just from the LLVM trunk. ::”h]”(hŒ¹To generate an AutoFDO profile, two offline tools are available: create_llvm_prof and llvm_profgen. The create_llvm_prof tool is part of the AutoFDO project and can be found on GitHub (”…””}”(hj/h²hh³Nh´NubhŒ reference”“”)”}”(hŒ!https://github.com/google/autofdo”h]”hŒ!https://github.com/google/autofdo”…””}”(hj9h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œrefuri”j;uh1j7hj/ubhX), version v0.30.1 or later. The llvm_profgen tool is included in the LLVM compiler itself. It’s important to note that the version of llvm_profgen doesn’t need to match the version of Clang. It needs to be the LLVM 19 release of Clang or later, or just from the LLVM trunk.”…””}”(hj/h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K’hj+ubj»)”}”(hŒS$ llvm-profgen --kernel --binary= --perfdata= -o ”h]”hŒS$ llvm-profgen --kernel --binary= --perfdata= -o ”…””}”hjRsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jºh³hÇh´K›hj+ubhÞ)”}”(hŒor ::”h]”hŒor”…””}”(hj`h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´Khj+ubj»)”}”(hŒc$ create_llvm_prof --binary= --profile= --format=extbinary --out=”h]”hŒc$ create_llvm_prof --binary= --profile= --format=extbinary --out=”…””}”hjnsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jºh³hÇh´KŸhj+ubhÞ)”}”(hŒENote that multiple AutoFDO profile files can be merged into one via::”h]”hŒDNote that multiple AutoFDO profile files can be merged into one via:”…””}”(hj|h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K¡hj+ubj»)”}”(hŒO$ llvm-profdata merge -o ... ”h]”hŒO$ llvm-profdata merge -o ... ”…””}”hjŠsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jºh³hÇh´K£hj+ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j8hj½h²hh³hÇh´Nubj9)”}”(hŒºRebuild the kernel using the AutoFDO profile file with the same config as step 1, (Note CONFIG_AUTOFDO_CLANG needs to be enabled):: $ make LLVM=1 CLANG_AUTOFDO_PROFILE=”h]”(hÞ)”}”(hŒƒRebuild the kernel using the AutoFDO profile file with the same config as step 1, (Note CONFIG_AUTOFDO_CLANG needs to be enabled)::”h]”hŒ‚Rebuild the kernel using the AutoFDO profile file with the same config as step 1, (Note CONFIG_AUTOFDO_CLANG needs to be enabled):”…””}”(hj¢h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K¥hjžubj»)”}”(hŒ2$ make LLVM=1 CLANG_AUTOFDO_PROFILE=”h]”hŒ2$ make LLVM=1 CLANG_AUTOFDO_PROFILE=”…””}”hj°sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jºh³hÇh´K¨hjžubeh}”(h]”h ]”h"]”h$]”h&]”uh1j8hj½h²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”jˆj‰jŠhj‹Œ)”uh1j3hjžh²hh³hÇh´Keubeh}”(h]”Œworkflow”ah ]”h"]”Œworkflow”ah$]”h&]”uh1hÈhhÊh²hh³hÇh´Kaubeh}”(h]”Œ#using-autofdo-with-the-linux-kernel”ah ]”h"]”Œ#using autofdo with the linux kernel”ah$]”h&]”uh1hÈhhh²hh³hÇh´Kubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”hÇuh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)”}”(hÍNŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”jþŒerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”hÇŒ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”Œnameids”}”(jØjÕjÏjÌj›j˜jÐjÍuŒ nametypes”}”(j؉jωj›‰jЉuh}”(jÕhÊjÌj›j˜jÒjÍjžuŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”…”R”Œparse_messages”]”Œtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nh²hub.