€•w[Œ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/mm/allocation-profiling”Œ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/mm/allocation-profiling”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ+/translations/it_IT/mm/allocation-profiling”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ+/translations/ja_JP/mm/allocation-profiling”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ+/translations/ko_KR/mm/allocation-profiling”Œ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/mm/allocation-profiling”Œ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/mm/allocation-profiling”Œ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³ŒE/var/lib/git/docbuild/linux/Documentation/mm/allocation-profiling.rst”h´KubhŒsection”“”)”}”(hhh]”(hŒtitle”“”)”}”(hŒMEMORY ALLOCATION PROFILING”h]”hŒMEMORY ALLOCATION PROFILING”…””}”(hhÏh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhhÊh²hh³hÇh´KubhŒ paragraph”“”)”}”(hŒmLow overhead (suitable for production) accounting of all memory allocations, tracked by file and line number.”h]”hŒmLow overhead (suitable for production) accounting of all memory allocations, tracked by file and line number.”…””}”(hhßh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´KhhÊh²hubhÞ)”}”(hŒ4Usage: kconfig options: - CONFIG_MEM_ALLOC_PROFILING”h]”hŒ4Usage: kconfig options: - CONFIG_MEM_ALLOC_PROFILING”…””}”(hhíh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K hhÊh²hubhŒ bullet_list”“”)”}”(hhh]”(hŒ list_item”“”)”}”(hŒ.CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT ”h]”hÞ)”}”(hŒ-CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT”h]”hŒ-CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´Khjubah}”(h]”h ]”h"]”h$]”h&]”uh1jhhýh²hh³hÇh´Nubj)”}”(hŒvCONFIG_MEM_ALLOC_PROFILING_DEBUG adds warnings for allocations that weren't accounted because of a missing annotation ”h]”hÞ)”}”(hŒuCONFIG_MEM_ALLOC_PROFILING_DEBUG adds warnings for allocations that weren't accounted because of a missing annotation”h]”hŒwCONFIG_MEM_ALLOC_PROFILING_DEBUG adds warnings for allocations that weren’t accounted because of a missing annotation”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´Khjubah}”(h]”h ]”h"]”h$]”h&]”uh1jhhýh²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”Œbullet”Œ-”uh1hûh³hÇh´KhhÊh²hubhŒdefinition_list”“”)”}”(hhh]”(hŒdefinition_list_item”“”)”}”(hX©Boot parameter: sysctl.vm.mem_profiling={0|1|never}[,compressed] When set to "never", memory allocation profiling overhead is minimized and it cannot be enabled at runtime (sysctl becomes read-only). When CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT=y, default value is "1". When CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT=n, default value is "never". "compressed" optional parameter will try to store page tag references in a compact format, avoiding page extensions. This results in improved performance and memory consumption, however it might fail depending on system configuration. If compression fails, a warning is issued and memory allocation profiling gets disabled. ”h]”(hŒterm”“”)”}”(hŒBoot parameter:”h]”hŒBoot parameter:”…””}”(hjGh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jEh³hÇh´KhjAubhŒ definition”“”)”}”(hhh]”(hÞ)”}”(hŒ0sysctl.vm.mem_profiling={0|1|never}[,compressed]”h]”hŒ0sysctl.vm.mem_profiling={0|1|never}[,compressed]”…””}”(hjZh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´KhjWubhÞ)”}”(hXfWhen set to "never", memory allocation profiling overhead is minimized and it cannot be enabled at runtime (sysctl becomes read-only). When CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT=y, default value is "1". When CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT=n, default value is "never". "compressed" optional parameter will try to store page tag references in a compact format, avoiding page extensions. This results in improved performance and memory consumption, however it might fail depending on system configuration. If compression fails, a warning is issued and memory allocation profiling gets disabled.”h]”hXvWhen set to “neverâ€, memory allocation profiling overhead is minimized and it cannot be enabled at runtime (sysctl becomes read-only). When CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT=y, default value is “1â€. When CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT=n, default value is “neverâ€. “compressed†optional parameter will try to store page tag references in a compact format, avoiding page extensions. This results in improved performance and memory consumption, however it might fail depending on system configuration. If compression fails, a warning is issued and memory allocation profiling gets disabled.”…””}”(hjhh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´KhjWubeh}”(h]”h ]”h"]”h$]”h&]”uh1jUhjAubeh}”(h]”h ]”h"]”h$]”h&]”uh1j?h³hÇh´Khj<ubj@)”}”(hXØsysctl: /proc/sys/vm/mem_profiling 1: Enable memory profiling. 0: Disable memory profiling. The default value depends on CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT. When CONFIG_MEM_ALLOC_PROFILING_DEBUG=y, this control is read-only to avoid warnings produced by allocations made while profiling is disabled and freed when it's enabled. /proc/sys/vm/mem_profiling_compressed 1: Page alloc tag compression is enabled. 0: Page alloc tag compression is disabled. This reflects a static boot-time configuration of how page allocation tags are stored (in page flags when compression is enabled and in page_ext when disabled). Toggling ``mem_profiling`` at runtime does not change the state of ``mem_profiling_compressed``. ”h]”(jF)”}”(hŒsysctl:”h]”hŒsysctl:”…””}”(hj†h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jEh³hÇh´K7hj‚ubjV)”}”(hhh]”(hÞ)”}”(hŒ/proc/sys/vm/mem_profiling”h]”hŒ/proc/sys/vm/mem_profiling”…””}”(hj—h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K"hj”ubhÞ)”}”(hŒ1: Enable memory profiling.”h]”hŒ1: Enable memory profiling.”…””}”(hj¥h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K$hj”ubhÞ)”}”(hŒ0: Disable memory profiling.”h]”hŒ0: Disable memory profiling.”…””}”(hj³h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K&hj”ubhÞ)”}”(hŒKThe default value depends on CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT.”h]”hŒKThe default value depends on CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT.”…””}”(hjÁh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K(hj”ubhÞ)”}”(hŒªWhen CONFIG_MEM_ALLOC_PROFILING_DEBUG=y, this control is read-only to avoid warnings produced by allocations made while profiling is disabled and freed when it's enabled.”h]”hŒ¬When CONFIG_MEM_ALLOC_PROFILING_DEBUG=y, this control is read-only to avoid warnings produced by allocations made while profiling is disabled and freed when it’s enabled.”…””}”(hjÏh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K*hj”ubhÞ)”}”(hŒ%/proc/sys/vm/mem_profiling_compressed”h]”hŒ%/proc/sys/vm/mem_profiling_compressed”…””}”(hjÝh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K.hj”ubhÞ)”}”(hŒ)1: Page alloc tag compression is enabled.”h]”hŒ)1: Page alloc tag compression is enabled.”…””}”(hjëh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K0hj”ubhÞ)”}”(hŒ*0: Page alloc tag compression is disabled.”h]”hŒ*0: Page alloc tag compression is disabled.”…””}”(hjùh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K2hj”ubhÞ)”}”(hXThis reflects a static boot-time configuration of how page allocation tags are stored (in page flags when compression is enabled and in page_ext when disabled). Toggling ``mem_profiling`` at runtime does not change the state of ``mem_profiling_compressed``.”h]”(hŒªThis reflects a static boot-time configuration of how page allocation tags are stored (in page flags when compression is enabled and in page_ext when disabled). Toggling ”…””}”(hjh²hh³Nh´NubhŒliteral”“”)”}”(hŒ``mem_profiling``”h]”hŒ mem_profiling”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubhŒ) at runtime does not change the state of ”…””}”(hjh²hh³Nh´Nubj)”}”(hŒ``mem_profiling_compressed``”h]”hŒmem_profiling_compressed”…””}”(hj#h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubhŒ.”…””}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K4hj”ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jUhj‚ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j?h³hÇh´K7hj<h²hubj@)”}”(hXiRuntime info: /proc/allocinfo Profiling data can be retrieved either by reading `/proc/allocinfo` directly as text or programmatically via `ioctl()` calls defined in ``. The ioctl interface supports structured binary data extraction as well as filtering by module name, function, file, line number, accuracy, or allocation size limits. ”h]”(jF)”}”(hŒ Runtime info:”h]”hŒ Runtime info:”…””}”(hjKh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jEh³hÇh´K?hjGubjV)”}”(hhh]”(hÞ)”}”(hŒ/proc/allocinfo”h]”hŒ/proc/allocinfo”…””}”(hj\h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K:hjYubhÞ)”}”(hXIProfiling data can be retrieved either by reading `/proc/allocinfo` directly as text or programmatically via `ioctl()` calls defined in ``. The ioctl interface supports structured binary data extraction as well as filtering by module name, function, file, line number, accuracy, or allocation size limits.”h]”(hŒ2Profiling data can be retrieved either by reading ”…””}”(hjjh²hh³Nh´NubhŒtitle_reference”“”)”}”(hŒ`/proc/allocinfo`”h]”hŒ/proc/allocinfo”…””}”(hjth²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jrhjjubhŒ* directly as text or programmatically via ”…””}”(hjjh²hh³Nh´Nubjs)”}”(hŒ `ioctl()`”h]”hŒioctl()”…””}”(hj†h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jrhjjubhŒ calls defined in ”…””}”(hjjh²hh³Nh´Nubjs)”}”(hŒ``”h]”hŒ”…””}”(hj˜h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jrhjjubhŒ§. The ioctl interface supports structured binary data extraction as well as filtering by module name, function, file, line number, accuracy, or allocation size limits.”…””}”(hjjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´Kh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´Knhj:ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj7h²hh³hÇh´Nubj)”}”(hŒ`define a macro version of foo() like so: #define foo(...) alloc_hooks(foo_noprof(__VA_ARGS__)) ”h]”(hÞ)”}”(hŒ(define a macro version of foo() like so:”h]”hŒ(define a macro version of foo() like so:”…””}”(hjVh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´KphjRubhÞ)”}”(hŒ5#define foo(...) alloc_hooks(foo_noprof(__VA_ARGS__))”h]”hŒ5#define foo(...) alloc_hooks(foo_noprof(__VA_ARGS__))”…””}”(hjdh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´KrhjRubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhj7h²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”j8j9uh1hûh³hÇh´Knhjàh²hubhÞ)”}”(hŒRIt's also possible to stash a pointer to an alloc tag in your own data structures.”h]”hŒTIt’s also possible to stash a pointer to an alloc tag in your own data structures.”…””}”(hj~h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´Kthjàh²hubhÞ)”}”(hXDo this when you're implementing a generic data structure that does allocations "on behalf of" some other code - for example, the rhashtable code. This way, instead of seeing a large line in /proc/allocinfo for rhashtable.c, we can break it out by rhashtable type.”h]”hXDo this when you’re implementing a generic data structure that does allocations “on behalf of†some other code - for example, the rhashtable code. This way, instead of seeing a large line in /proc/allocinfo for rhashtable.c, we can break it out by rhashtable type.”…””}”(hjŒh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´Kvhjàh²hubhÞ)”}”(hŒYTo do so: - Hook your data structure's init function, like any other allocation function.”h]”hŒ[To do so: - Hook your data structure’s init function, like any other allocation function.”…””}”(hjšh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K{hjàh²hubhü)”}”(hhh]”(j)”}”(hŒtWithin your init function, use the convenience macro alloc_tag_record() to record alloc tag in your data structure. ”h]”hÞ)”}”(hŒsWithin your init function, use the convenience macro alloc_tag_record() to record alloc tag in your data structure.”h]”hŒsWithin your init function, use the convenience macro alloc_tag_record() to record alloc tag in your data structure.”…””}”(hj¯h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K~hj«ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj¨h²hh³hÇh´Nubj)”}”(hŒlThen, use the following form for your allocations: alloc_hooks_tag(ht->your_saved_tag, kmalloc_noprof(...)) ”h]”hÞ)”}”(hŒkThen, use the following form for your allocations: alloc_hooks_tag(ht->your_saved_tag, kmalloc_noprof(...))”h]”hŒkThen, use the following form for your allocations: alloc_hooks_tag(ht->your_saved_tag, kmalloc_noprof(...))”…””}”(hjÇh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´KhjÃubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj¨h²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”j8j9uh1hûh³hÇh´K~hjàh²hubeh}”(h]”Œtheory-of-operation”ah ]”h"]”Œtheory of operation”ah$]”h&]”uh1hÈhhÊh²hh³hÇh´KQubhÉ)”}”(hhh]”(hÎ)”}”(hŒNotes”h]”hŒNotes”…””}”(hjìh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjéh²hh³hÇh´K…ubhü)”}”(hhh]”j)”}”(hŒ¢When a slab object is allocated from KFENCE, its accounting is skipped. KFENCE allocations are rare and limited to a small number, so this omission is negligible.”h]”hÞ)”}”(hŒ¢When a slab object is allocated from KFENCE, its accounting is skipped. KFENCE allocations are rare and limited to a small number, so this omission is negligible.”h]”hŒ¢When a slab object is allocated from KFENCE, its accounting is skipped. KFENCE allocations are rare and limited to a small number, so this omission is negligible.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K‡hjýubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjúh²hh³hÇh´Nubah}”(h]”h ]”h"]”h$]”h&]”j8j9uh1hûh³hÇh´K‡hjéh²hubeh}”(h]”Œnotes”ah ]”h"]”Œnotes”ah$]”h&]”uh1hÈhhÊh²hh³hÇh´K…ubeh}”(h]”Œmemory-allocation-profiling”ah ]”h"]”Œmemory allocation profiling”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”jNŒ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 juŒ nametypes”}”(j(‰jæ‰j ‰uh}”(j%hÊjãjàjjé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.