Dsphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget,/translations/zh_CN/admin-guide/mm/transhugemodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget,/translations/zh_TW/admin-guide/mm/transhugemodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget,/translations/it_IT/admin-guide/mm/transhugemodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget,/translations/ja_JP/admin-guide/mm/transhugemodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget,/translations/ko_KR/admin-guide/mm/transhugemodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget,/translations/sp_SP/admin-guide/mm/transhugemodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhsection)}(hhh](htitle)}(hTransparent Hugepage Supporth]hTransparent Hugepage Support}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhF/var/lib/git/docbuild/linux/Documentation/admin-guide/mm/transhuge.rsthKubh)}(hhh](h)}(h Objectiveh]h Objective}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh paragraph)}(hXPerformance critical computing applications dealing with large memory working sets are already running on top of libhugetlbfs and in turn hugetlbfs. Transparent HugePage Support (THP) is an alternative mean of using huge pages for the backing of virtual memory with huge pages that supports the automatic promotion and demotion of page sizes and without the shortcomings of hugetlbfs.h]hXPerformance critical computing applications dealing with large memory working sets are already running on top of libhugetlbfs and in turn hugetlbfs. Transparent HugePage Support (THP) is an alternative mean of using huge pages for the backing of virtual memory with huge pages that supports the automatic promotion and demotion of page sizes and without the shortcomings of hugetlbfs.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(h}Currently THP only works for anonymous memory mappings and tmpfs/shmem. But in the future it can expand to other filesystems.h]h}Currently THP only works for anonymous memory mappings and tmpfs/shmem. But in the future it can expand to other filesystems.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubhnote)}(hin the examples below we presume that the basic page size is 4K and the huge page size is 2M, although the actual numbers may vary depending on the CPU architecture.h]h)}(hin the examples below we presume that the basic page size is 4K and the huge page size is 2M, although the actual numbers may vary depending on the CPU architecture.h]hin the examples below we presume that the basic page size is 4K and the huge page size is 2M, although the actual numbers may vary depending on the CPU architecture.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhubah}(h]h ]h"]h$]h&]uh1hhhhhhhhNubh)}(hXThe reason applications are running faster is because of two factors. The first factor is almost completely irrelevant and it's not of significant interest because it'll also have the downside of requiring larger clear-page copy-page in page faults which is a potentially negative effect. The first factor consists in taking a single page fault for each 2M virtual region touched by userland (so reducing the enter/exit kernel frequency by a 512 times factor). This only matters the first time the memory is accessed for the lifetime of a memory mapping. The second long lasting and much more important factor will affect all subsequent accesses to the memory for the whole runtime of the application. The second factor consist of two components:h]hXThe reason applications are running faster is because of two factors. The first factor is almost completely irrelevant and it’s not of significant interest because it’ll also have the downside of requiring larger clear-page copy-page in page faults which is a potentially negative effect. The first factor consists in taking a single page fault for each 2M virtual region touched by userland (so reducing the enter/exit kernel frequency by a 512 times factor). This only matters the first time the memory is accessed for the lifetime of a memory mapping. The second long lasting and much more important factor will affect all subsequent accesses to the memory for the whole runtime of the application. The second factor consist of two components:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubhenumerated_list)}(hhh](h list_item)}(hthe TLB miss will run faster (especially with virtualization using nested pagetables but almost always also on bare metal without virtualization) h]h)}(hthe TLB miss will run faster (especially with virtualization using nested pagetables but almost always also on bare metal without virtualization)h]hthe TLB miss will run faster (especially with virtualization using nested pagetables but almost always also on bare metal without virtualization)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK$hjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(hXa single TLB entry will be mapping a much larger amount of virtual memory in turn reducing the number of TLB misses. With virtualization and nested pagetables the TLB can be mapped of larger size only if both KVM and the Linux guest are using hugepages but a significant speedup already happens if only one of the two is using hugepages just because of the fact the TLB miss is going to run faster. h]h)}(hXa single TLB entry will be mapping a much larger amount of virtual memory in turn reducing the number of TLB misses. With virtualization and nested pagetables the TLB can be mapped of larger size only if both KVM and the Linux guest are using hugepages but a significant speedup already happens if only one of the two is using hugepages just because of the fact the TLB miss is going to run faster.h]hXa single TLB entry will be mapping a much larger amount of virtual memory in turn reducing the number of TLB misses. With virtualization and nested pagetables the TLB can be mapped of larger size only if both KVM and the Linux guest are using hugepages but a significant speedup already happens if only one of the two is using hugepages just because of the fact the TLB miss is going to run faster.}(hj1hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK(hj-ubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubeh}(h]h ]h"]h$]h&]enumtypearabicprefixhsuffix)uh1jhhhhhhhK$ubh)}(hXwModern kernels support "multi-size THP" (mTHP), which introduces the ability to allocate memory in blocks that are bigger than a base page but smaller than traditional PMD-size (as described above), in increments of a power-of-2 number of pages. mTHP can back anonymous memory (for example 16K, 32K, 64K, etc). These THPs continue to be PTE-mapped, but in many cases can still provide similar benefits to those outlined above: Page faults are significantly reduced (by a factor of e.g. 4, 8, 16, etc), but latency spikes are much less prominent because the size of each page isn't as huge as the PMD-sized variant and there is less memory to clear in each page fault. Some architectures also employ TLB compression mechanisms to squeeze more entries in when a set of PTEs are virtually and physically contiguous and approporiately aligned. In this case, TLB misses will occur less often.h]hX}Modern kernels support “multi-size THP” (mTHP), which introduces the ability to allocate memory in blocks that are bigger than a base page but smaller than traditional PMD-size (as described above), in increments of a power-of-2 number of pages. mTHP can back anonymous memory (for example 16K, 32K, 64K, etc). These THPs continue to be PTE-mapped, but in many cases can still provide similar benefits to those outlined above: Page faults are significantly reduced (by a factor of e.g. 4, 8, 16, etc), but latency spikes are much less prominent because the size of each page isn’t as huge as the PMD-sized variant and there is less memory to clear in each page fault. Some architectures also employ TLB compression mechanisms to squeeze more entries in when a set of PTEs are virtually and physically contiguous and approporiately aligned. In this case, TLB misses will occur less often.}(hjPhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK0hhhhubh)}(hXTHP can be enabled system wide or restricted to certain tasks or even memory ranges inside task's address space. Unless THP is completely disabled, there is ``khugepaged`` daemon that scans memory and collapses sequences of basic pages into PMD-sized huge pages.h](hTHP can be enabled system wide or restricted to certain tasks or even memory ranges inside task’s address space. Unless THP is completely disabled, there is }(hj^hhhNhNubhliteral)}(h``khugepaged``h]h khugepaged}(hjhhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj^ubh[ daemon that scans memory and collapses sequences of basic pages into PMD-sized huge pages.}(hj^hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK?hhhhubh)}(hvThe THP behaviour is controlled via :ref:`sysfs ` interface and using madvise(2) and prctl(2) system calls.h](h$The THP behaviour is controlled via }(hjhhhNhNubh)}(h:ref:`sysfs `h]hinline)}(hjh]hsysfs}(hjhhhNhNubah}(h]h ](xrefstdstd-refeh"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]refdocadmin-guide/mm/transhuge refdomainjreftyperef refexplicitrefwarn reftarget thp_sysfsuh1hhhhKDhjubh: interface and using madvise(2) and prctl(2) system calls.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKDhhhhubh)}(hXTransparent Hugepage Support maximizes the usefulness of free memory if compared to the reservation approach of hugetlbfs by allowing all unused memory to be used as cache or other movable (or even unmovable entities). It doesn't require reservation to prevent hugepage allocation failures to be noticeable from userland. It allows paging and all other advanced VM features to be available on the hugepages. It requires no modifications for applications to take advantage of it.h]hXTransparent Hugepage Support maximizes the usefulness of free memory if compared to the reservation approach of hugetlbfs by allowing all unused memory to be used as cache or other movable (or even unmovable entities). It doesn’t require reservation to prevent hugepage allocation failures to be noticeable from userland. It allows paging and all other advanced VM features to be available on the hugepages. It requires no modifications for applications to take advantage of it.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKGhhhhubh)}(hX{Applications however can be further optimized to take advantage of this feature, like for example they've been optimized before to avoid a flood of mmap system calls for every malloc(4k). Optimizing userland is by far not mandatory and khugepaged already can take care of long lived page allocations even for hugepage unaware applications that deals with large amounts of memory.h]hX}Applications however can be further optimized to take advantage of this feature, like for example they’ve been optimized before to avoid a flood of mmap system calls for every malloc(4k). Optimizing userland is by far not mandatory and khugepaged already can take care of long lived page allocations even for hugepage unaware applications that deals with large amounts of memory.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKPhhhhubh)}(hXxIn certain cases when hugepages are enabled system wide, application may end up allocating more memory resources. An application may mmap a large region but only touch 1 byte of it, in that case a 2M page might be allocated instead of a 4k page for no good. This is why it's possible to disable hugepages system-wide and to only have them inside MADV_HUGEPAGE madvise regions.h]hXzIn certain cases when hugepages are enabled system wide, application may end up allocating more memory resources. An application may mmap a large region but only touch 1 byte of it, in that case a 2M page might be allocated instead of a 4k page for no good. This is why it’s possible to disable hugepages system-wide and to only have them inside MADV_HUGEPAGE madvise regions.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKWhhhhubh)}(hEmbedded systems should enable hugepages only inside madvise regions to eliminate any risk of wasting any precious byte of memory and to only run faster.h]hEmbedded systems should enable hugepages only inside madvise regions to eliminate any risk of wasting any precious byte of memory and to only run faster.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK^hhhhubh)}(hApplications that gets a lot of benefit from hugepages and that don't risk to lose memory by using hugepages, should use madvise(MADV_HUGEPAGE) on their critical mmapped regions.h]hApplications that gets a lot of benefit from hugepages and that don’t risk to lose memory by using hugepages, should use madvise(MADV_HUGEPAGE) on their critical mmapped regions.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKbhhhhubhtarget)}(h.. _thp_sysfs:h]h}(h]h ]h"]h$]h&]refid thp-sysfsuh1jhKfhhhhhhubeh}(h] objectiveah ]h"] objectiveah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hsysfsh]hsysfs}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKiubh)}(hhh](h)}(hGlobal THP controlsh]hGlobal THP controls}(hj'hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj$hhhhhKlubh)}(hXTransparent Hugepage Support for anonymous memory can be disabled (mostly for debugging purposes) or only enabled inside MADV_HUGEPAGE regions (to avoid the risk of consuming more memory resources) or enabled system wide. This can be achieved per-supported-THP-size with one of::h]hXTransparent Hugepage Support for anonymous memory can be disabled (mostly for debugging purposes) or only enabled inside MADV_HUGEPAGE regions (to avoid the risk of consuming more memory resources) or enabled system wide. This can be achieved per-supported-THP-size with one of:}(hj5hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKnhj$hhubh literal_block)}(hecho always >/sys/kernel/mm/transparent_hugepage/hugepages-kB/enabled echo madvise >/sys/kernel/mm/transparent_hugepage/hugepages-kB/enabled echo never >/sys/kernel/mm/transparent_hugepage/hugepages-kB/enabledh]hecho always >/sys/kernel/mm/transparent_hugepage/hugepages-kB/enabled echo madvise >/sys/kernel/mm/transparent_hugepage/hugepages-kB/enabled echo never >/sys/kernel/mm/transparent_hugepage/hugepages-kB/enabled}hjEsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1jChhhKshj$hhubh)}(h`where is the hugepage size being addressed, the available sizes for which vary by system.h]h`where is the hugepage size being addressed, the available sizes for which vary by system.}(hjUhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKwhj$hhubh)}(hSetting "never" in all sysfs THP controls does **not** disable Transparent Huge Pages globally. This is because ``madvise(..., MADV_COLLAPSE)`` ignores these settings and collapses ranges to PMD-sized huge pages unconditionally.h]h)}(hSetting "never" in all sysfs THP controls does **not** disable Transparent Huge Pages globally. This is because ``madvise(..., MADV_COLLAPSE)`` ignores these settings and collapses ranges to PMD-sized huge pages unconditionally.h](h3Setting “never” in all sysfs THP controls does }(hjghhhNhNubhstrong)}(h**not**h]hnot}(hjqhhhNhNubah}(h]h ]h"]h$]h&]uh1johjgubh: disable Transparent Huge Pages globally. This is because }(hjghhhNhNubjg)}(h``madvise(..., MADV_COLLAPSE)``h]hmadvise(..., MADV_COLLAPSE)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjgubhU ignores these settings and collapses ranges to PMD-sized huge pages unconditionally.}(hjghhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKzhjcubah}(h]h ]h"]h$]h&]uh1hhj$hhhhhNubh)}(h For example::h]h For example:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj$hhubjD)}(hIecho always >/sys/kernel/mm/transparent_hugepage/hugepages-2048kB/enabledh]hIecho always >/sys/kernel/mm/transparent_hugepage/hugepages-2048kB/enabled}hjsbah}(h]h ]h"]h$]h&]jSjTuh1jChhhKhj$hhubh)}(hoAlternatively it is possible to specify that a given hugepage size will inherit the top-level "enabled" value::h]hrAlternatively it is possible to specify that a given hugepage size will inherit the top-level “enabled” value:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj$hhubjD)}(hLecho inherit >/sys/kernel/mm/transparent_hugepage/hugepages-kB/enabledh]hLecho inherit >/sys/kernel/mm/transparent_hugepage/hugepages-kB/enabled}hjsbah}(h]h ]h"]h$]h&]jSjTuh1jChhhKhj$hhubh)}(h For example::h]h For example:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj$hhubjD)}(hJecho inherit >/sys/kernel/mm/transparent_hugepage/hugepages-2048kB/enabledh]hJecho inherit >/sys/kernel/mm/transparent_hugepage/hugepages-2048kB/enabled}hjsbah}(h]h ]h"]h$]h&]jSjTuh1jChhhKhj$hhubh)}(hdThe top-level setting (for use with "inherit") can be set by issuing one of the following commands::h]hgThe top-level setting (for use with “inherit”) can be set by issuing one of the following commands:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj$hhubjD)}(hecho always >/sys/kernel/mm/transparent_hugepage/enabled echo madvise >/sys/kernel/mm/transparent_hugepage/enabled echo never >/sys/kernel/mm/transparent_hugepage/enabledh]hecho always >/sys/kernel/mm/transparent_hugepage/enabled echo madvise >/sys/kernel/mm/transparent_hugepage/enabled echo never >/sys/kernel/mm/transparent_hugepage/enabled}hjsbah}(h]h ]h"]h$]h&]jSjTuh1jChhhKhj$hhubh)}(hBy default, PMD-sized hugepages have enabled="inherit" and all other hugepage sizes have enabled="never". If enabling multiple hugepage sizes, the kernel will select the most appropriate enabled size for a given allocation.h]hBy default, PMD-sized hugepages have enabled=”inherit” and all other hugepage sizes have enabled=”never”. If enabling multiple hugepage sizes, the kernel will select the most appropriate enabled size for a given allocation.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj$hhubh)}(hXIt's also possible to limit defrag efforts in the VM to generate anonymous hugepages in case they're not immediately free to madvise regions or to never try to defrag memory and simply fallback to regular pages unless hugepages are immediately available. Clearly if we spend CPU time to defrag memory, we would expect to gain even more by the fact we use hugepages later instead of regular pages. This isn't always guaranteed, but it may be more likely in case the allocation is for a MADV_HUGEPAGE region.h]hXIt’s also possible to limit defrag efforts in the VM to generate anonymous hugepages in case they’re not immediately free to madvise regions or to never try to defrag memory and simply fallback to regular pages unless hugepages are immediately available. Clearly if we spend CPU time to defrag memory, we would expect to gain even more by the fact we use hugepages later instead of regular pages. This isn’t always guaranteed, but it may be more likely in case the allocation is for a MADV_HUGEPAGE region.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj$hhubjD)}(hXecho always >/sys/kernel/mm/transparent_hugepage/defrag echo defer >/sys/kernel/mm/transparent_hugepage/defrag echo defer+madvise >/sys/kernel/mm/transparent_hugepage/defrag echo madvise >/sys/kernel/mm/transparent_hugepage/defrag echo never >/sys/kernel/mm/transparent_hugepage/defragh]hXecho always >/sys/kernel/mm/transparent_hugepage/defrag echo defer >/sys/kernel/mm/transparent_hugepage/defrag echo defer+madvise >/sys/kernel/mm/transparent_hugepage/defrag echo madvise >/sys/kernel/mm/transparent_hugepage/defrag echo never >/sys/kernel/mm/transparent_hugepage/defrag}hj-sbah}(h]h ]h"]h$]h&]jSjTuh1jChhhKhj$hhubhdefinition_list)}(hhh](hdefinition_list_item)}(hX/always means that an application requesting THP will stall on allocation failure and directly reclaim pages and compact memory in an effort to allocate a THP immediately. This may be desirable for virtual machines that benefit heavily from THP use and are willing to delay the VM start to utilise them. h](hterm)}(halwaysh]halways}(hjHhhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhKhjBubh definition)}(hhh]h)}(hX'means that an application requesting THP will stall on allocation failure and directly reclaim pages and compact memory in an effort to allocate a THP immediately. This may be desirable for virtual machines that benefit heavily from THP use and are willing to delay the VM start to utilise them.h]hX'means that an application requesting THP will stall on allocation failure and directly reclaim pages and compact memory in an effort to allocate a THP immediately. This may be desirable for virtual machines that benefit heavily from THP use and are willing to delay the VM start to utilise them.}(hj[hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjXubah}(h]h ]h"]h$]h&]uh1jVhjBubeh}(h]h ]h"]h$]h&]uh1j@hhhKhj=ubjA)}(hdefer means that an application will wake kswapd in the background to reclaim pages and wake kcompactd to compact memory so that THP is available in the near future. It's the responsibility of khugepaged to then install the THP pages later. h](jG)}(hdeferh]hdefer}(hjyhhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhKhjuubjW)}(hhh]h)}(hmeans that an application will wake kswapd in the background to reclaim pages and wake kcompactd to compact memory so that THP is available in the near future. It's the responsibility of khugepaged to then install the THP pages later.h]hmeans that an application will wake kswapd in the background to reclaim pages and wake kcompactd to compact memory so that THP is available in the near future. It’s the responsibility of khugepaged to then install the THP pages later.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jVhjuubeh}(h]h ]h"]h$]h&]uh1j@hhhKhj=hhubjA)}(hXdefer+madvise will enter direct reclaim and compaction like ``always``, but only for regions that have used madvise(MADV_HUGEPAGE); all other regions will wake kswapd in the background to reclaim pages and wake kcompactd to compact memory so that THP is available in the near future. h](jG)}(h defer+madviseh]h defer+madvise}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhKhjubjW)}(hhh]h)}(hX will enter direct reclaim and compaction like ``always``, but only for regions that have used madvise(MADV_HUGEPAGE); all other regions will wake kswapd in the background to reclaim pages and wake kcompactd to compact memory so that THP is available in the near future.h](h.will enter direct reclaim and compaction like }(hjhhhNhNubjg)}(h ``always``h]halways}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjubh, but only for regions that have used madvise(MADV_HUGEPAGE); all other regions will wake kswapd in the background to reclaim pages and wake kcompactd to compact memory so that THP is available in the near future.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jVhjubeh}(h]h ]h"]h$]h&]uh1j@hhhKhj=hhubjA)}(hmadvise will enter direct reclaim like ``always`` but only for regions that are have used madvise(MADV_HUGEPAGE). This is the default behaviour. h](jG)}(hmadviseh]hmadvise}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhKhjubjW)}(hhh]h)}(hwill enter direct reclaim like ``always`` but only for regions that are have used madvise(MADV_HUGEPAGE). This is the default behaviour.h](hwill enter direct reclaim like }(hjhhhNhNubjg)}(h ``always``h]halways}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjubh_ but only for regions that are have used madvise(MADV_HUGEPAGE). This is the default behaviour.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jVhjubeh}(h]h ]h"]h$]h&]uh1j@hhhKhj=hhubjA)}(hnever should be self-explanatory. Note that ``madvise(..., MADV_COLLAPSE)`` can still cause transparent huge pages to be obtained even if this mode is specified everywhere. h](jG)}(hneverh]hnever}(hj*hhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhKhj&ubjW)}(hhh]h)}(hshould be self-explanatory. Note that ``madvise(..., MADV_COLLAPSE)`` can still cause transparent huge pages to be obtained even if this mode is specified everywhere.h](h&should be self-explanatory. Note that }(hj;hhhNhNubjg)}(h``madvise(..., MADV_COLLAPSE)``h]hmadvise(..., MADV_COLLAPSE)}(hjChhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj;ubha can still cause transparent huge pages to be obtained even if this mode is specified everywhere.}(hj;hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj8ubah}(h]h ]h"]h$]h&]uh1jVhj&ubeh}(h]h ]h"]h$]h&]uh1j@hhhKhj=hhubeh}(h]h ]h"]h$]h&]uh1j;hj$hhhhhNubh)}(hBy default kernel tries to use huge, PMD-mappable zero page on read page fault to anonymous mapping. It's possible to disable huge zero page by writing 0 or enable it back by writing 1::h]hBy default kernel tries to use huge, PMD-mappable zero page on read page fault to anonymous mapping. It’s possible to disable huge zero page by writing 0 or enable it back by writing 1:}(hjmhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj$hhubjD)}(hsecho 0 >/sys/kernel/mm/transparent_hugepage/use_zero_page echo 1 >/sys/kernel/mm/transparent_hugepage/use_zero_pageh]hsecho 0 >/sys/kernel/mm/transparent_hugepage/use_zero_page echo 1 >/sys/kernel/mm/transparent_hugepage/use_zero_page}hj{sbah}(h]h ]h"]h$]h&]jSjTuh1jChhhKhj$hhubh)}(hSome userspace (such as a test program, or an optimized memory allocation library) may want to know the size (in bytes) of a PMD-mappable transparent hugepage::h]hSome userspace (such as a test program, or an optimized memory allocation library) may want to know the size (in bytes) of a PMD-mappable transparent hugepage:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj$hhubjD)}(h6cat /sys/kernel/mm/transparent_hugepage/hpage_pmd_sizeh]h6cat /sys/kernel/mm/transparent_hugepage/hpage_pmd_size}hjsbah}(h]h ]h"]h$]h&]jSjTuh1jChhhKhj$hhubh)}(hXlAll THPs at fault and collapse time will be added to _deferred_list, and will therefore be split under memory presure if they are considered "underused". A THP is underused if the number of zero-filled pages in the THP is above max_ptes_none (see below). It is possible to disable this behaviour by writing 0 to shrink_underused, and enable it by writing 1 to it::h]hXoAll THPs at fault and collapse time will be added to _deferred_list, and will therefore be split under memory presure if they are considered “underused”. A THP is underused if the number of zero-filled pages in the THP is above max_ptes_none (see below). It is possible to disable this behaviour by writing 0 to shrink_underused, and enable it by writing 1 to it:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj$hhubjD)}(h{echo 0 > /sys/kernel/mm/transparent_hugepage/shrink_underused echo 1 > /sys/kernel/mm/transparent_hugepage/shrink_underusedh]h{echo 0 > /sys/kernel/mm/transparent_hugepage/shrink_underused echo 1 > /sys/kernel/mm/transparent_hugepage/shrink_underused}hjsbah}(h]h ]h"]h$]h&]jSjTuh1jChhhKhj$hhubh)}(hX6khugepaged will be automatically started when PMD-sized THP is enabled (either of the per-size anon control or the top-level control are set to "always" or "madvise"), and it'll be automatically shutdown when PMD-sized THP is disabled (when both the per-size anon control and the top-level control are "never")h]hXDkhugepaged will be automatically started when PMD-sized THP is enabled (either of the per-size anon control or the top-level control are set to “always” or “madvise”), and it’ll be automatically shutdown when PMD-sized THP is disabled (when both the per-size anon control and the top-level control are “never”)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj$hhubeh}(h]global-thp-controlsah ]h"]global thp controlsah$]h&]uh1hhjhhhhhKlubh)}(hhh](h)}(hKhugepaged controlsh]hKhugepaged controls}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hkhugepaged currently only searches for opportunities to collapse to PMD-sized THP and no attempt is made to collapse to other THP sizes.h]h)}(hkhugepaged currently only searches for opportunities to collapse to PMD-sized THP and no attempt is made to collapse to other THP sizes.h]hkhugepaged currently only searches for opportunities to collapse to PMD-sized THP and no attempt is made to collapse to other THP sizes.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(hX5khugepaged runs usually at low frequency so while one may not want to invoke defrag algorithms synchronously during the page faults, it should be worth invoking defrag at least in khugepaged. However it's also possible to disable defrag in khugepaged by writing 0 or enable defrag in khugepaged by writing 1::h]hX6khugepaged runs usually at low frequency so while one may not want to invoke defrag algorithms synchronously during the page faults, it should be worth invoking defrag at least in khugepaged. However it’s also possible to disable defrag in khugepaged by writing 0 or enable defrag in khugepaged by writing 1:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubjD)}(h{echo 0 >/sys/kernel/mm/transparent_hugepage/khugepaged/defrag echo 1 >/sys/kernel/mm/transparent_hugepage/khugepaged/defragh]h{echo 0 >/sys/kernel/mm/transparent_hugepage/khugepaged/defrag echo 1 >/sys/kernel/mm/transparent_hugepage/khugepaged/defrag}hjsbah}(h]h ]h"]h$]h&]jSjTuh1jChhhKhjhhubh)}(hIYou can also control how many pages khugepaged should scan at each pass::h]hHYou can also control how many pages khugepaged should scan at each pass:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubjD)}(h/sys/kernel/mm/transparent_hugepage/khugepaged/pages_collapsedh]h>/sys/kernel/mm/transparent_hugepage/khugepaged/pages_collapsed}hj~sbah}(h]h ]h"]h$]h&]jSjTuh1jChhhM hjhhubh)}(hfor each pass::h]hfor each pass:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubjD)}(h9/sys/kernel/mm/transparent_hugepage/khugepaged/full_scansh]h9/sys/kernel/mm/transparent_hugepage/khugepaged/full_scans}hjsbah}(h]h ]h"]h$]h&]jSjTuh1jChhhMhjhhubh)}(h``max_ptes_none`` specifies how many extra small pages (that are not already mapped) can be allocated when collapsing a group of small pages into one large page::h](jg)}(h``max_ptes_none``h]h max_ptes_none}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjubh specifies how many extra small pages (that are not already mapped) can be allocated when collapsing a group of small pages into one large page:}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjhhubjD)}(h/sys/kernel/mm/transparent_hugepage/khugepaged/max_ptes_sharedh]h>/sys/kernel/mm/transparent_hugepage/khugepaged/max_ptes_shared}hj4sbah}(h]h ]h"]h$]h&]jSjTuh1jChhhM,hjhhubh)}(h@A higher value may increase memory footprint for some workloads.h]h@A higher value may increase memory footprint for some workloads.}(hjBhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM.hjhhubeh}(h]khugepaged-controlsah ]h"]khugepaged controlsah$]h&]uh1hhjhhhhhKubeh}(h](sysfsj eh ]h"](sysfs thp_sysfseh$]h&]uh1hhhhhhhhKiexpect_referenced_by_name}j^jsexpect_referenced_by_id}j jsubh)}(hhh](h)}(hBoot parametersh]hBoot parameters}(hjhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjehhhhhM1ubh)}(hYou can change the sysfs boot time default for the top-level "enabled" control by passing the parameter ``transparent_hugepage=always`` or ``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` to the kernel command line.h](hlYou can change the sysfs boot time default for the top-level “enabled” control by passing the parameter }(hjvhhhNhNubjg)}(h``transparent_hugepage=always``h]htransparent_hugepage=always}(hj~hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjvubh or }(hjvhhhNhNubjg)}(h ``transparent_hugepage=madvise``h]htransparent_hugepage=madvise}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjvubh or }(hjvhhhNhNubjg)}(h``transparent_hugepage=never``h]htransparent_hugepage=never}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjvubh to the kernel command line.}(hjvhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM3hjehhubh)}(hXJAlternatively, each supported anonymous THP size can be controlled by passing ``thp_anon=[KMG],[KMG]:;[KMG]-[KMG]:``, where ```` is the THP size (must be a power of 2 of PAGE_SIZE and supported anonymous THP) and ```` is one of ``always``, ``madvise``, ``never`` or ``inherit``.h](hNAlternatively, each supported anonymous THP size can be controlled by passing }(hjhhhNhNubjg)}(hL``thp_anon=[KMG],[KMG]:;[KMG]-[KMG]:``h]hHthp_anon=[KMG],[KMG]:;[KMG]-[KMG]:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjubh, where }(hjhhhNhNubjg)}(h ````h]h}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjubhV is the THP size (must be a power of 2 of PAGE_SIZE and supported anonymous THP) and }(hjhhhNhNubjg)}(h ````h]h}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjubh is one of }(hjhhhNhNubjg)}(h ``always``h]halways}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjubh, }(hjhhhNhNubjg)}(h ``madvise``h]hmadvise}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjubh, }(hjhhhNhNubjg)}(h ``never``h]hnever}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjubh or }(hjhhhNhNubjg)}(h ``inherit``h]hinherit}(hj.hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjubh.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM8hjehhubh)}(hFor example, the following will set 16K, 32K, 64K THP to ``always``, set 128K, 512K to ``inherit``, set 256K to ``madvise`` and 1M, 2M to ``never``::h](h9For example, the following will set 16K, 32K, 64K THP to }(hjFhhhNhNubjg)}(h ``always``h]halways}(hjNhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjFubh, set 128K, 512K to }(hjFhhhNhNubjg)}(h ``inherit``h]hinherit}(hj`hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjFubh, set 256K to }(hjFhhhNhNubjg)}(h ``madvise``h]hmadvise}(hjrhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjFubh and 1M, 2M to }(hjFhhhNhNubjg)}(h ``never``h]hnever}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjFubh:}(hjFhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM>hjehhubjD)}(hBthp_anon=16K-64K:always;128K,512K:inherit;256K:madvise;1M-2M:neverh]hBthp_anon=16K-64K:always;128K,512K:inherit;256K:madvise;1M-2M:never}hjsbah}(h]h ]h"]h$]h&]jSjTuh1jChhhMBhjehhubh)}(h``thp_anon=`` may be specified multiple times to configure all THP sizes as required. If ``thp_anon=`` is specified at least once, any anon THP sizes not explicitly configured on the command line are implicitly set to ``never``.h](jg)}(h ``thp_anon=``h]h thp_anon=}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjubhL may be specified multiple times to configure all THP sizes as required. If }(hjhhhNhNubjg)}(h ``thp_anon=``h]h thp_anon=}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjubht is specified at least once, any anon THP sizes not explicitly configured on the command line are implicitly set to }(hjhhhNhNubjg)}(h ``never``h]hnever}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjubh.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMDhjehhubh)}(hXj``transparent_hugepage`` setting only affects the global toggle. If ``thp_anon`` is not specified, PMD_ORDER THP will default to ``inherit``. However, if a valid ``thp_anon`` setting is provided by the user, the PMD_ORDER THP policy will be overridden. If the policy for PMD_ORDER is not defined within a valid ``thp_anon``, its policy will default to ``never``.h](jg)}(h``transparent_hugepage``h]htransparent_hugepage}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjubh, setting only affects the global toggle. If }(hjhhhNhNubjg)}(h ``thp_anon``h]hthp_anon}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjubh1 is not specified, PMD_ORDER THP will default to }(hjhhhNhNubjg)}(h ``inherit``h]hinherit}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjubh. However, if a valid }(hjhhhNhNubjg)}(h ``thp_anon``h]hthp_anon}(hj$hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjubh setting is provided by the user, the PMD_ORDER THP policy will be overridden. If the policy for PMD_ORDER is not defined within a valid }(hjhhhNhNubjg)}(h ``thp_anon``h]hthp_anon}(hj6hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjubh, its policy will default to }(hjhhhNhNubjg)}(h ``never``h]hnever}(hjHhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjubh.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMIhjehhubh)}(hXHSimilarly to ``transparent_hugepage``, you can control the hugepage allocation policy for the internal shmem mount by using the kernel parameter ``transparent_hugepage_shmem=``, where ```` is one of the seven valid policies for shmem (``always``, ``within_size``, ``advise``, ``never``, ``deny``, and ``force``).h](h Similarly to }(hj`hhhNhNubjg)}(h``transparent_hugepage``h]htransparent_hugepage}(hjhhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj`ubhl, you can control the hugepage allocation policy for the internal shmem mount by using the kernel parameter }(hj`hhhNhNubjg)}(h'``transparent_hugepage_shmem=``h]h#transparent_hugepage_shmem=}(hjzhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj`ubh, where }(hj`hhhNhNubjg)}(h ````h]h}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj`ubh/ is one of the seven valid policies for shmem (}(hj`hhhNhNubjg)}(h ``always``h]halways}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj`ubh, }(hj`hhhNhNubjg)}(h``within_size``h]h within_size}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj`ubh, }hj`sbjg)}(h ``advise``h]hadvise}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj`ubh, }(hj`hhhNhNubjg)}(h ``never``h]hnever}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj`ubh, }hj`sbjg)}(h``deny``h]hdeny}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj`ubh, and }(hj`hhhNhNubjg)}(h ``force``h]hforce}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj`ubh).}(hj`hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMPhjehhubh)}(hX`Similarly to ``transparent_hugepage_shmem``, you can control the default hugepage allocation policy for the tmpfs mount by using the kernel parameter ``transparent_hugepage_tmpfs=``, where ```` is one of the four valid policies for tmpfs (``always``, ``within_size``, ``advise``, ``never``). The tmpfs mount default policy is ``never``.h](h Similarly to }(hj hhhNhNubjg)}(h``transparent_hugepage_shmem``h]htransparent_hugepage_shmem}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj ubhk, you can control the default hugepage allocation policy for the tmpfs mount by using the kernel parameter }(hj hhhNhNubjg)}(h'``transparent_hugepage_tmpfs=``h]h#transparent_hugepage_tmpfs=}(hj* hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj ubh, where }(hj hhhNhNubjg)}(h ````h]h}(hj< hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj ubh. is one of the four valid policies for tmpfs (}(hj hhhNhNubjg)}(h ``always``h]halways}(hjN hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj ubh, }(hj hhhNhNubjg)}(h``within_size``h]h within_size}(hj` hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj ubh, }hj sbjg)}(h ``advise``h]hadvise}(hjr hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj ubh, }(hj hhhNhNubjg)}(h ``never``h]hnever}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj ubh%). The tmpfs mount default policy is }(hj hhhNhNubjg)}(h ``never``h]hnever}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj ubh.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMVhjehhubh)}(hIn the same manner as ``thp_anon`` controls each supported anonymous THP size, ``thp_shmem`` controls each supported shmem THP size. ``thp_shmem`` has the same format as ``thp_anon``, but also supports the policy ``within_size``.h](hIn the same manner as }(hj hhhNhNubjg)}(h ``thp_anon``h]hthp_anon}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj ubh- controls each supported anonymous THP size, }(hj hhhNhNubjg)}(h ``thp_shmem``h]h thp_shmem}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj ubh) controls each supported shmem THP size. }(hj hhhNhNubjg)}(h ``thp_shmem``h]h thp_shmem}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj ubh has the same format as }(hj hhhNhNubjg)}(h ``thp_anon``h]hthp_anon}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj ubh, but also supports the policy }(hj hhhNhNubjg)}(h``within_size``h]h within_size}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj ubh.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM\hjehhubh)}(h``thp_shmem=`` may be specified multiple times to configure all THP sizes as required. If ``thp_shmem=`` is specified at least once, any shmem THP sizes not explicitly configured on the command line are implicitly set to ``never``.h](jg)}(h``thp_shmem=``h]h thp_shmem=}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj ubhL may be specified multiple times to configure all THP sizes as required. If }(hj hhhNhNubjg)}(h``thp_shmem=``h]h thp_shmem=}(hj, hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj ubhu is specified at least once, any shmem THP sizes not explicitly configured on the command line are implicitly set to }(hj hhhNhNubjg)}(h ``never``h]hnever}(hj> hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj ubh.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMahjehhubh)}(hX}``transparent_hugepage_shmem`` setting only affects the global toggle. If ``thp_shmem`` is not specified, PMD_ORDER hugepage will default to ``inherit``. However, if a valid ``thp_shmem`` setting is provided by the user, the PMD_ORDER hugepage policy will be overridden. If the policy for PMD_ORDER is not defined within a valid ``thp_shmem``, its policy will default to ``never``.h](jg)}(h``transparent_hugepage_shmem``h]htransparent_hugepage_shmem}(hjZ hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjV ubh, setting only affects the global toggle. If }(hjV hhhNhNubjg)}(h ``thp_shmem``h]h thp_shmem}(hjl hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjV ubh6 is not specified, PMD_ORDER hugepage will default to }(hjV hhhNhNubjg)}(h ``inherit``h]hinherit}(hj~ hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjV ubh. However, if a valid }(hjV hhhNhNubjg)}(h ``thp_shmem``h]h thp_shmem}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjV ubh setting is provided by the user, the PMD_ORDER hugepage policy will be overridden. If the policy for PMD_ORDER is not defined within a valid }(hjV hhhNhNubjg)}(h ``thp_shmem``h]h thp_shmem}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjV ubh, its policy will default to }(hjV hhhNhNubjg)}(h ``never``h]hnever}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjV ubh.}(hjV hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMfhjehhubeh}(h]boot-parametersah ]h"]boot parametersah$]h&]uh1hhhhhhhhM1ubh)}(hhh](h)}(hHugepages in tmpfs/shmemh]hHugepages in tmpfs/shmem}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhMnubh)}(hXTraditionally, tmpfs only supported a single huge page size ("PMD"). Today, it also supports smaller sizes just like anonymous memory, often referred to as "multi-size THP" (mTHP). Huge pages of any size are commonly represented in the kernel as "large folios".h]hXTraditionally, tmpfs only supported a single huge page size (“PMD”). Today, it also supports smaller sizes just like anonymous memory, often referred to as “multi-size THP” (mTHP). Huge pages of any size are commonly represented in the kernel as “large folios”.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMphj hhubh)}(hWhile there is fine control over the huge page sizes to use for the internal shmem mount (see below), ordinary tmpfs mounts will make use of all available huge page sizes without any control over the exact sizes, behaving more like other file systems.h]hWhile there is fine control over the huge page sizes to use for the internal shmem mount (see below), ordinary tmpfs mounts will make use of all available huge page sizes without any control over the exact sizes, behaving more like other file systems.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMuhj hhubh)}(hhh](h)}(h tmpfs mountsh]h tmpfs mounts}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhM{ubh)}(h{The THP allocation policy for tmpfs mounts can be adjusted using the mount option: ``huge=``. It can have following values:h](hSThe THP allocation policy for tmpfs mounts can be adjusted using the mount option: }(hj hhhNhNubjg)}(h ``huge=``h]hhuge=}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj ubh. It can have following values:}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM}hj hhubj<)}(hhh](jA)}(hEalways Attempt to allocate huge pages every time we need a new page; h](jG)}(halwaysh]halways}(hj9 hhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMhj5 ubjW)}(hhh]h)}(h=Attempt to allocate huge pages every time we need a new page;h]h=Attempt to allocate huge pages every time we need a new page;}(hjJ hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjG ubah}(h]h ]h"]h$]h&]uh1jVhj5 ubeh}(h]h ]h"]h$]h&]uh1j@hhhMhj2 ubjA)}(hnever Do not allocate huge pages. Note that ``madvise(..., MADV_COLLAPSE)`` can still cause transparent huge pages to be obtained even if this mode is specified everywhere; h](jG)}(hneverh]hnever}(hjh hhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMhjd ubjW)}(hhh]h)}(hDo not allocate huge pages. Note that ``madvise(..., MADV_COLLAPSE)`` can still cause transparent huge pages to be obtained even if this mode is specified everywhere;h](h&Do not allocate huge pages. Note that }(hjy hhhNhNubjg)}(h``madvise(..., MADV_COLLAPSE)``h]hmadvise(..., MADV_COLLAPSE)}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjy ubha can still cause transparent huge pages to be obtained even if this mode is specified everywhere;}(hjy hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjv ubah}(h]h ]h"]h$]h&]uh1jVhjd ubeh}(h]h ]h"]h$]h&]uh1j@hhhMhj2 hhubjA)}(hewithin_size Only allocate huge page if it will be fully within i_size. Also respect madvise() hints; h](jG)}(h within_sizeh]h within_size}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMhj ubjW)}(hhh]h)}(hXOnly allocate huge page if it will be fully within i_size. Also respect madvise() hints;h]hXOnly allocate huge page if it will be fully within i_size. Also respect madvise() hints;}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jVhj ubeh}(h]h ]h"]h$]h&]uh1j@hhhMhj2 hhubjA)}(h=advise Only allocate huge pages if requested with madvise(); h](jG)}(hadviseh]hadvise}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMhj ubjW)}(hhh]h)}(h5Only allocate huge pages if requested with madvise();h]h5Only allocate huge pages if requested with madvise();}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jVhj ubeh}(h]h ]h"]h$]h&]uh1j@hhhMhj2 hhubeh}(h]h ]h"]h$]h&]uh1j;hj hhhhhNubh)}(hRemember, that the kernel may use huge pages of all available sizes, and that no fine control as for the internal tmpfs mount is available.h]hRemember, that the kernel may use huge pages of all available sizes, and that no fine control as for the internal tmpfs mount is available.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(hThe default policy in the past was ``never``, but it can now be adjusted using the kernel parameter ``transparent_hugepage_tmpfs=``.h](h#The default policy in the past was }(hj hhhNhNubjg)}(h ``never``h]hnever}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj ubh8, but it can now be adjusted using the kernel parameter }(hj hhhNhNubjg)}(h'``transparent_hugepage_tmpfs=``h]h#transparent_hugepage_tmpfs=}(hj1 hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj ubh.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(h``mount -o remount,huge= /mountpoint`` works fine after mount: remounting ``huge=never`` will not attempt to break up huge pages at all, just stop more from being allocated.h](jg)}(h&``mount -o remount,huge= /mountpoint``h]h"mount -o remount,huge= /mountpoint}(hjM hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjI ubh$ works fine after mount: remounting }(hjI hhhNhNubjg)}(h``huge=never``h]h huge=never}(hj_ hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjI ubhU will not attempt to break up huge pages at all, just stop more from being allocated.}(hjI hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(hIn addition to policies listed above, the sysfs knob /sys/kernel/mm/transparent_hugepage/shmem_enabled will affect the allocation policy of tmpfs mounts, when set to the following values:h]hIn addition to policies listed above, the sysfs knob /sys/kernel/mm/transparent_hugepage/shmem_enabled will affect the allocation policy of tmpfs mounts, when set to the following values:}(hjw hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubj<)}(hhh](jA)}(hJdeny For use in emergencies, to force the huge option off from all mounts;h](jG)}(hdenyh]hdeny}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMhj ubjW)}(hhh]h)}(hEFor use in emergencies, to force the huge option off from all mounts;h]hEFor use in emergencies, to force the huge option off from all mounts;}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jVhj ubeh}(h]h ]h"]h$]h&]uh1j@hhhMhj ubjA)}(hBforce Force the huge option on for all - very useful for testing; h](jG)}(hforceh]hforce}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMhj ubjW)}(hhh]h)}(h;Force the huge option on for all - very useful for testing;h]h;Force the huge option on for all - very useful for testing;}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jVhj ubeh}(h]h ]h"]h$]h&]uh1j@hhhMhj hhubeh}(h]h ]h"]h$]h&]uh1j;hj hhhhhNubeh}(h] tmpfs-mountsah ]h"] tmpfs mountsah$]h&]uh1hhj hhhhhM{ubh)}(hhh](h)}(hshmem / internal tmpfsh]hshmem / internal tmpfs}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhMubh)}(hThe mount internal tmpfs mount is used for SysV SHM, memfds, shared anonymous mmaps (of /dev/zero or MAP_ANONYMOUS), GPU drivers' DRM objects, Ashmem.h]hThe mount internal tmpfs mount is used for SysV SHM, memfds, shared anonymous mmaps (of /dev/zero or MAP_ANONYMOUS), GPU drivers’ DRM objects, Ashmem.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(hTo control the THP allocation policy for this internal tmpfs mount, the sysfs knob /sys/kernel/mm/transparent_hugepage/shmem_enabled and the knobs per THP size in '/sys/kernel/mm/transparent_hugepage/hugepages-kB/shmem_enabled' can be used.h]hTo control the THP allocation policy for this internal tmpfs mount, the sysfs knob /sys/kernel/mm/transparent_hugepage/shmem_enabled and the knobs per THP size in ‘/sys/kernel/mm/transparent_hugepage/hugepages-kB/shmem_enabled’ can be used.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(hThe global knob has the same semantics as the ``huge=`` mount options for tmpfs mounts, except that the different huge page sizes can be controlled individually, and will only use the setting of the global knob when the per-size knob is set to 'inherit'.h](h.The global knob has the same semantics as the }(hj! hhhNhNubjg)}(h ``huge=``h]hhuge=}(hj) hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj! ubh mount options for tmpfs mounts, except that the different huge page sizes can be controlled individually, and will only use the setting of the global knob when the per-size knob is set to ‘inherit’.}(hj! hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(hzThe options 'force' and 'deny' are dropped for the individual sizes, which are rather testing artifacts from the old ages.h]hThe options ‘force’ and ‘deny’ are dropped for the individual sizes, which are rather testing artifacts from the old ages.}(hjA hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubj<)}(hhh](jA)}(hLalways Attempt to allocate huge pages every time we need a new page; h](jG)}(halwaysh]halways}(hjV hhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMhjR ubjW)}(hhh]h)}(hDAttempt to allocate huge pages every time we need a new page;h]hDAttempt to allocate huge pages every time we need a new page;}(hjg hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjd ubah}(h]h ]h"]h$]h&]uh1jVhjR ubeh}(h]h ]h"]h$]h&]uh1j@hhhMhjO ubjA)}(hinherit Inherit the top-level "shmem_enabled" value. By default, PMD-sized hugepages have enabled="inherit" and all other hugepage sizes have enabled="never"; h](jG)}(hinherith]hinherit}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMhj ubjW)}(hhh]h)}(hInherit the top-level "shmem_enabled" value. By default, PMD-sized hugepages have enabled="inherit" and all other hugepage sizes have enabled="never";h]hInherit the top-level “shmem_enabled” value. By default, PMD-sized hugepages have enabled=”inherit” and all other hugepage sizes have enabled=”never”;}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jVhj ubeh}(h]h ]h"]h$]h&]uh1j@hhhMhjO hhubjA)}(hnever Do not allocate huge pages. Note that ``madvise(..., MADV_COLLAPSE)`` can still cause transparent huge pages to be obtained even if this mode is specified everywhere; h](jG)}(hneverh]hnever}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMhj ubjW)}(hhh]h)}(hDo not allocate huge pages. Note that ``madvise(..., MADV_COLLAPSE)`` can still cause transparent huge pages to be obtained even if this mode is specified everywhere;h](h-Do not allocate huge pages. Note that }(hj hhhNhNubjg)}(h``madvise(..., MADV_COLLAPSE)``h]hmadvise(..., MADV_COLLAPSE)}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj ubha can still cause transparent huge pages to be obtained even if this mode is specified everywhere;}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jVhj ubeh}(h]h ]h"]h$]h&]uh1j@hhhMhjO hhubjA)}(hlwithin_size Only allocate huge page if it will be fully within i_size. Also respect madvise() hints; h](jG)}(h within_sizeh]h within_size}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMhj ubjW)}(hhh]h)}(h_Only allocate huge page if it will be fully within i_size. Also respect madvise() hints;h]h_Only allocate huge page if it will be fully within i_size. Also respect madvise() hints;}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1jVhj ubeh}(h]h ]h"]h$]h&]uh1j@hhhMhjO hhubjA)}(hDadvise Only allocate huge pages if requested with madvise(); h](jG)}(hadviseh]hadvise}(hj$hhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMhj ubjW)}(hhh]h)}(h huge pages if requested with madvise();h]h huge pages if requested with madvise();}(hj5hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj2ubah}(h]h ]h"]h$]h&]uh1jVhj ubeh}(h]h ]h"]h$]h&]uh1j@hhhMhjO hhubeh}(h]h ]h"]h$]h&]uh1j;hj hhhhhNubeh}(h]shmem-internal-tmpfsah ]h"]shmem / internal tmpfsah$]h&]uh1hhj hhhhhMubeh}(h]hugepages-in-tmpfs-shmemah ]h"]hugepages in tmpfs/shmemah$]h&]uh1hhhhhhhhMnubh)}(hhh](h)}(hNeed of application restarth]hNeed of application restart}(hjhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjehhhhhMubh)}(hX.The transparent_hugepage/enabled and transparent_hugepage/hugepages-kB/enabled values and tmpfs mount option only affect future behavior. So to make them effective you need to restart any application that could have been using hugepages. This also applies to the regions registered in khugepaged.h]hX.The transparent_hugepage/enabled and transparent_hugepage/hugepages-kB/enabled values and tmpfs mount option only affect future behavior. So to make them effective you need to restart any application that could have been using hugepages. This also applies to the regions registered in khugepaged.}(hjvhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjehhubeh}(h]need-of-application-restartah ]h"]need of application restartah$]h&]uh1hhhhhhhhMubh)}(hhh](h)}(hMonitoring usageh]hMonitoring usage}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMubh)}(hXThe number of PMD-sized anonymous transparent huge pages currently used by the system is available by reading the AnonHugePages field in ``/proc/meminfo``. To identify what applications are using PMD-sized anonymous transparent huge pages, it is necessary to read ``/proc/PID/smaps`` and count the AnonHugePages fields for each mapping. (Note that AnonHugePages only applies to traditional PMD-sized THP for historical reasons and should have been called AnonHugePmdMapped).h](hThe number of PMD-sized anonymous transparent huge pages currently used by the system is available by reading the AnonHugePages field in }(hjhhhNhNubjg)}(h``/proc/meminfo``h]h /proc/meminfo}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjubhn. To identify what applications are using PMD-sized anonymous transparent huge pages, it is necessary to read }(hjhhhNhNubjg)}(h``/proc/PID/smaps``h]h/proc/PID/smaps}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjubh and count the AnonHugePages fields for each mapping. (Note that AnonHugePages only applies to traditional PMD-sized THP for historical reasons and should have been called AnonHugePmdMapped).}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hX<The number of file transparent huge pages mapped to userspace is available by reading ShmemPmdMapped and ShmemHugePages fields in ``/proc/meminfo``. To identify what applications are mapping file transparent huge pages, it is necessary to read ``/proc/PID/smaps`` and count the FilePmdMapped fields for each mapping.h](hThe number of file transparent huge pages mapped to userspace is available by reading ShmemPmdMapped and ShmemHugePages fields in }(hjhhhNhNubjg)}(h``/proc/meminfo``h]h /proc/meminfo}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjubha. To identify what applications are mapping file transparent huge pages, it is necessary to read }(hjhhhNhNubjg)}(h``/proc/PID/smaps``h]h/proc/PID/smaps}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjubh5 and count the FilePmdMapped fields for each mapping.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(h\Note that reading the smaps file is expensive and reading it frequently will incur overhead.h]h\Note that reading the smaps file is expensive and reading it frequently will incur overhead.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hThere are a number of counters in ``/proc/vmstat`` that may be used to monitor how successfully the system is providing huge pages for use.h](h"There are a number of counters in }(hjhhhNhNubjg)}(h``/proc/vmstat``h]h /proc/vmstat}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjubhY that may be used to monitor how successfully the system is providing huge pages for use.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjhhubj<)}(hhh](jA)}(htthp_fault_alloc is incremented every time a huge page is successfully allocated and charged to handle a page fault. h](jG)}(hthp_fault_alloch]hthp_fault_alloc}(hj6hhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMhj2ubjW)}(hhh]h)}(hcis incremented every time a huge page is successfully allocated and charged to handle a page fault.h]hcis incremented every time a huge page is successfully allocated and charged to handle a page fault.}(hjGhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjDubah}(h]h ]h"]h$]h&]uh1jVhj2ubeh}(h]h ]h"]h$]h&]uh1j@hhhMhj/ubjA)}(hthp_collapse_alloc is incremented by khugepaged when it has found a range of pages to collapse into one huge page and has successfully allocated a new huge page to store the data. h](jG)}(hthp_collapse_alloch]hthp_collapse_alloc}(hjehhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMhjaubjW)}(hhh]h)}(his incremented by khugepaged when it has found a range of pages to collapse into one huge page and has successfully allocated a new huge page to store the data.h]his incremented by khugepaged when it has found a range of pages to collapse into one huge page and has successfully allocated a new huge page to store the data.}(hjvhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjsubah}(h]h ]h"]h$]h&]uh1jVhjaubeh}(h]h ]h"]h$]h&]uh1j@hhhMhj/hhubjA)}(hthp_fault_fallback is incremented if a page fault fails to allocate or charge a huge page and instead falls back to using small pages. h](jG)}(hthp_fault_fallbackh]hthp_fault_fallback}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMhjubjW)}(hhh]h)}(hsis incremented if a page fault fails to allocate or charge a huge page and instead falls back to using small pages.h]hsis incremented if a page fault fails to allocate or charge a huge page and instead falls back to using small pages.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1jVhjubeh}(h]h ]h"]h$]h&]uh1j@hhhMhj/hhubjA)}(hthp_fault_fallback_charge is incremented if a page fault fails to charge a huge page and instead falls back to using small pages even though the allocation was successful. h](jG)}(hthp_fault_fallback_chargeh]hthp_fault_fallback_charge}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMhjubjW)}(hhh]h)}(his incremented if a page fault fails to charge a huge page and instead falls back to using small pages even though the allocation was successful.h]his incremented if a page fault fails to charge a huge page and instead falls back to using small pages even though the allocation was successful.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1jVhjubeh}(h]h ]h"]h$]h&]uh1j@hhhMhj/hhubjA)}(hthp_collapse_alloc_failed is incremented if khugepaged found a range of pages that should be collapsed into one huge page but failed the allocation. h](jG)}(hthp_collapse_alloc_failedh]hthp_collapse_alloc_failed}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMhjubjW)}(hhh]h)}(hzis incremented if khugepaged found a range of pages that should be collapsed into one huge page but failed the allocation.h]hzis incremented if khugepaged found a range of pages that should be collapsed into one huge page but failed the allocation.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1jVhjubeh}(h]h ]h"]h$]h&]uh1j@hhhMhj/hhubjA)}(hthp_file_alloc is incremented every time a shmem huge page is successfully allocated (Note that despite being named after "file", the counter measures only shmem). h](jG)}(hthp_file_alloch]hthp_file_alloc}(hj!hhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMhjubjW)}(hhh]h)}(his incremented every time a shmem huge page is successfully allocated (Note that despite being named after "file", the counter measures only shmem).h]his incremented every time a shmem huge page is successfully allocated (Note that despite being named after “file”, the counter measures only shmem).}(hj2hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj/ubah}(h]h ]h"]h$]h&]uh1jVhjubeh}(h]h ]h"]h$]h&]uh1j@hhhMhj/hhubjA)}(hthp_file_fallback is incremented if a shmem huge page is attempted to be allocated but fails and instead falls back to using small pages. (Note that despite being named after "file", the counter measures only shmem). h](jG)}(hthp_file_fallbackh]hthp_file_fallback}(hjPhhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMhjLubjW)}(hhh]h)}(his incremented if a shmem huge page is attempted to be allocated but fails and instead falls back to using small pages. (Note that despite being named after "file", the counter measures only shmem).h]his incremented if a shmem huge page is attempted to be allocated but fails and instead falls back to using small pages. (Note that despite being named after “file”, the counter measures only shmem).}(hjahhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj^ubah}(h]h ]h"]h$]h&]uh1jVhjLubeh}(h]h ]h"]h$]h&]uh1j@hhhMhj/hhubjA)}(hthp_file_fallback_charge is incremented if a shmem huge page cannot be charged and instead falls back to using small pages even though the allocation was successful. (Note that despite being named after "file", the counter measures only shmem). h](jG)}(hthp_file_fallback_chargeh]hthp_file_fallback_charge}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMhj{ubjW)}(hhh]h)}(his incremented if a shmem huge page cannot be charged and instead falls back to using small pages even though the allocation was successful. (Note that despite being named after "file", the counter measures only shmem).h]his incremented if a shmem huge page cannot be charged and instead falls back to using small pages even though the allocation was successful. (Note that despite being named after “file”, the counter measures only shmem).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hjubah}(h]h ]h"]h$]h&]uh1jVhj{ubeh}(h]h ]h"]h$]h&]uh1j@hhhMhj/hhubjA)}(hgthp_file_mapped is incremented every time a file or shmem huge page is mapped into user address space. h](jG)}(hthp_file_mappedh]hthp_file_mapped}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMhjubjW)}(hhh]h)}(hVis incremented every time a file or shmem huge page is mapped into user address space.h]hVis incremented every time a file or shmem huge page is mapped into user address space.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1jVhjubeh}(h]h ]h"]h$]h&]uh1j@hhhMhj/hhubjA)}(hthp_split_page is incremented every time a huge page is split into base pages. This can happen for a variety of reasons but a common reason is that a huge page is old and is being reclaimed. This action implies splitting all PMD the page mapped with. h](jG)}(hthp_split_pageh]hthp_split_page}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMhjubjW)}(hhh]h)}(his incremented every time a huge page is split into base pages. This can happen for a variety of reasons but a common reason is that a huge page is old and is being reclaimed. This action implies splitting all PMD the page mapped with.h]his incremented every time a huge page is split into base pages. This can happen for a variety of reasons but a common reason is that a huge page is old and is being reclaimed. This action implies splitting all PMD the page mapped with.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1jVhjubeh}(h]h ]h"]h$]h&]uh1j@hhhMhj/hhubjA)}(h}thp_split_page_failed is incremented if kernel fails to split huge page. This can happen if the page was pinned by somebody. h](jG)}(hthp_split_page_failedh]hthp_split_page_failed}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMhjubjW)}(hhh]h)}(hfis incremented if kernel fails to split huge page. This can happen if the page was pinned by somebody.h]hfis incremented if kernel fails to split huge page. This can happen if the page was pinned by somebody.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1jVhjubeh}(h]h ]h"]h$]h&]uh1j@hhhMhj/hhubjA)}(hthp_deferred_split_page is incremented when a huge page is put onto split queue. This happens when a huge page is partially unmapped and splitting it would free up some memory. Pages on split queue are going to be split under memory pressure. h](jG)}(hthp_deferred_split_pageh]hthp_deferred_split_page}(hj;hhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhM"hj7ubjW)}(hhh]h)}(his incremented when a huge page is put onto split queue. This happens when a huge page is partially unmapped and splitting it would free up some memory. Pages on split queue are going to be split under memory pressure.h]his incremented when a huge page is put onto split queue. This happens when a huge page is partially unmapped and splitting it would free up some memory. Pages on split queue are going to be split under memory pressure.}(hjLhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjIubah}(h]h ]h"]h$]h&]uh1jVhj7ubeh}(h]h ]h"]h$]h&]uh1j@hhhM"hj/hhubjA)}(hXthp_underused_split_page is incremented when a huge page on the split queue was split because it was underused. A THP is underused if the number of zero pages in the THP is above a certain threshold (/sys/kernel/mm/transparent_hugepage/khugepaged/max_ptes_none). h](jG)}(hthp_underused_split_pageh]hthp_underused_split_page}(hjjhhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhM(hjfubjW)}(hhh]h)}(his incremented when a huge page on the split queue was split because it was underused. A THP is underused if the number of zero pages in the THP is above a certain threshold (/sys/kernel/mm/transparent_hugepage/khugepaged/max_ptes_none).h]his incremented when a huge page on the split queue was split because it was underused. A THP is underused if the number of zero pages in the THP is above a certain threshold (/sys/kernel/mm/transparent_hugepage/khugepaged/max_ptes_none).}(hj{hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM%hjxubah}(h]h ]h"]h$]h&]uh1jVhjfubeh}(h]h ]h"]h$]h&]uh1j@hhhM(hj/hhubjA)}(hthp_split_pmd is incremented every time a PMD split into table of PTEs. This can happen, for instance, when application calls mprotect() or munmap() on part of huge page. It doesn't split huge page, only page table entry. h](jG)}(h thp_split_pmdh]h thp_split_pmd}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhM.hjubjW)}(hhh]h)}(his incremented every time a PMD split into table of PTEs. This can happen, for instance, when application calls mprotect() or munmap() on part of huge page. It doesn't split huge page, only page table entry.h]his incremented every time a PMD split into table of PTEs. This can happen, for instance, when application calls mprotect() or munmap() on part of huge page. It doesn’t split huge page, only page table entry.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM+hjubah}(h]h ]h"]h$]h&]uh1jVhjubeh}(h]h ]h"]h$]h&]uh1j@hhhM.hj/hhubjA)}(hthp_zero_page_alloc is incremented every time a huge zero page used for thp is successfully allocated. Note, it doesn't count every map of the huge zero page, only its allocation. h](jG)}(hthp_zero_page_alloch]hthp_zero_page_alloc}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhM3hjubjW)}(hhh]h)}(his incremented every time a huge zero page used for thp is successfully allocated. Note, it doesn't count every map of the huge zero page, only its allocation.h]his incremented every time a huge zero page used for thp is successfully allocated. Note, it doesn’t count every map of the huge zero page, only its allocation.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM1hjubah}(h]h ]h"]h$]h&]uh1jVhjubeh}(h]h ]h"]h$]h&]uh1j@hhhM3hj/hhubjA)}(hzthp_zero_page_alloc_failed is incremented if kernel fails to allocate huge zero page and falls back to using small pages. h](jG)}(hthp_zero_page_alloc_failedh]hthp_zero_page_alloc_failed}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhM7hjubjW)}(hhh]h)}(h^is incremented if kernel fails to allocate huge zero page and falls back to using small pages.h]h^is incremented if kernel fails to allocate huge zero page and falls back to using small pages.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM6hjubah}(h]h ]h"]h$]h&]uh1jVhjubeh}(h]h ]h"]h$]h&]uh1j@hhhM7hj/hhubjA)}(h\thp_swpout is incremented every time a huge page is swapout in one piece without splitting. h](jG)}(h thp_swpouth]h thp_swpout}(hj&hhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhM;hj"ubjW)}(hhh]h)}(hPis incremented every time a huge page is swapout in one piece without splitting.h]hPis incremented every time a huge page is swapout in one piece without splitting.}(hj7hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM:hj4ubah}(h]h ]h"]h$]h&]uh1jVhj"ubeh}(h]h ]h"]h$]h&]uh1j@hhhM;hj/hhubjA)}(hthp_swpout_fallback is incremented if a huge page has to be split before swapout. Usually because failed to allocate some continuous swap space for the huge page. h](jG)}(hthp_swpout_fallbackh]hthp_swpout_fallback}(hjUhhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhM@hjQubjW)}(hhh]h)}(his incremented if a huge page has to be split before swapout. Usually because failed to allocate some continuous swap space for the huge page.h]his incremented if a huge page has to be split before swapout. Usually because failed to allocate some continuous swap space for the huge page.}(hjfhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM>hjcubah}(h]h ]h"]h$]h&]uh1jVhjQubeh}(h]h ]h"]h$]h&]uh1j@hhhM@hj/hhubeh}(h]h ]h"]h$]h&]uh1j;hjhhhhhNubh)}(hXIn /sys/kernel/mm/transparent_hugepage/hugepages-kB/stats, There are also individual counters for each huge page size, which can be utilized to monitor the system's effectiveness in providing huge pages for usage. Each counter has its own corresponding file.h]hX In /sys/kernel/mm/transparent_hugepage/hugepages-kB/stats, There are also individual counters for each huge page size, which can be utilized to monitor the system’s effectiveness in providing huge pages for usage. Each counter has its own corresponding file.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMBhjhhubj<)}(hhh](jA)}(huanon_fault_alloc is incremented every time a huge page is successfully allocated and charged to handle a page fault. h](jG)}(hanon_fault_alloch]hanon_fault_alloc}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMIhjubjW)}(hhh]h)}(hcis incremented every time a huge page is successfully allocated and charged to handle a page fault.h]hcis incremented every time a huge page is successfully allocated and charged to handle a page fault.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMHhjubah}(h]h ]h"]h$]h&]uh1jVhjubeh}(h]h ]h"]h$]h&]uh1j@hhhMIhjubjA)}(hanon_fault_fallback is incremented if a page fault fails to allocate or charge a huge page and instead falls back to using huge pages with lower orders or small pages. h](jG)}(hanon_fault_fallbackh]hanon_fault_fallback}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMNhjubjW)}(hhh]h)}(his incremented if a page fault fails to allocate or charge a huge page and instead falls back to using huge pages with lower orders or small pages.h]his incremented if a page fault fails to allocate or charge a huge page and instead falls back to using huge pages with lower orders or small pages.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMLhjubah}(h]h ]h"]h$]h&]uh1jVhjubeh}(h]h ]h"]h$]h&]uh1j@hhhMNhjhhubjA)}(hanon_fault_fallback_charge is incremented if a page fault fails to charge a huge page and instead falls back to using huge pages with lower orders or small pages even though the allocation was successful. h](jG)}(hanon_fault_fallback_chargeh]hanon_fault_fallback_charge}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMShjubjW)}(hhh]h)}(his incremented if a page fault fails to charge a huge page and instead falls back to using huge pages with lower orders or small pages even though the allocation was successful.h]his incremented if a page fault fails to charge a huge page and instead falls back to using huge pages with lower orders or small pages even though the allocation was successful.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMQhjubah}(h]h ]h"]h$]h&]uh1jVhjubeh}(h]h ]h"]h$]h&]uh1j@hhhMShjhhubjA)}(hfzswpout is incremented every time a huge page is swapped out to zswap in one piece without splitting. h](jG)}(hzswpouth]hzswpout}(hj(hhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMWhj$ubjW)}(hhh]h)}(h]is incremented every time a huge page is swapped out to zswap in one piece without splitting.h]h]is incremented every time a huge page is swapped out to zswap in one piece without splitting.}(hj9hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMVhj6ubah}(h]h ]h"]h$]h&]uh1jVhj$ubeh}(h]h ]h"]h$]h&]uh1j@hhhMWhjhhubjA)}(heswpin is incremented every time a huge page is swapped in from a non-zswap swap device in one piece. h](jG)}(hswpinh]hswpin}(hjWhhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhM[hjSubjW)}(hhh]h)}(h^is incremented every time a huge page is swapped in from a non-zswap swap device in one piece.h]h^is incremented every time a huge page is swapped in from a non-zswap swap device in one piece.}(hjhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMZhjeubah}(h]h ]h"]h$]h&]uh1jVhjSubeh}(h]h ]h"]h$]h&]uh1j@hhhM[hjhhubjA)}(hswpin_fallback is incremented if swapin fails to allocate or charge a huge page and instead falls back to using huge pages with lower orders or small pages. h](jG)}(hswpin_fallbackh]hswpin_fallback}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhM`hjubjW)}(hhh]h)}(his incremented if swapin fails to allocate or charge a huge page and instead falls back to using huge pages with lower orders or small pages.h]his incremented if swapin fails to allocate or charge a huge page and instead falls back to using huge pages with lower orders or small pages.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM^hjubah}(h]h ]h"]h$]h&]uh1jVhjubeh}(h]h ]h"]h$]h&]uh1j@hhhM`hjhhubjA)}(hswpin_fallback_charge is incremented if swapin fails to charge a huge page and instead falls back to using huge pages with lower orders or small pages even though the allocation was successful. h](jG)}(hswpin_fallback_chargeh]hswpin_fallback_charge}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMehjubjW)}(hhh]h)}(his incremented if swapin fails to charge a huge page and instead falls back to using huge pages with lower orders or small pages even though the allocation was successful.h]his incremented if swapin fails to charge a huge page and instead falls back to using huge pages with lower orders or small pages even though the allocation was successful.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMchjubah}(h]h ]h"]h$]h&]uh1jVhjubeh}(h]h ]h"]h$]h&]uh1j@hhhMehjhhubjA)}(hwswpout is incremented every time a huge page is swapped out to a non-zswap swap device in one piece without splitting. h](jG)}(hswpouth]hswpout}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMihjubjW)}(hhh]h)}(hois incremented every time a huge page is swapped out to a non-zswap swap device in one piece without splitting.h]hois incremented every time a huge page is swapped out to a non-zswap swap device in one piece without splitting.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhhjubah}(h]h ]h"]h$]h&]uh1jVhjubeh}(h]h ]h"]h$]h&]uh1j@hhhMihjhhubjA)}(hswpout_fallback is incremented if a huge page has to be split before swapout. Usually because failed to allocate some continuous swap space for the huge page. h](jG)}(hswpout_fallbackh]hswpout_fallback}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMnhjubjW)}(hhh]h)}(his incremented if a huge page has to be split before swapout. Usually because failed to allocate some continuous swap space for the huge page.h]his incremented if a huge page has to be split before swapout. Usually because failed to allocate some continuous swap space for the huge page.}(hj$hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMlhj!ubah}(h]h ]h"]h$]h&]uh1jVhjubeh}(h]h ]h"]h$]h&]uh1j@hhhMnhjhhubjA)}(hSshmem_alloc is incremented every time a shmem huge page is successfully allocated. h](jG)}(h shmem_alloch]h shmem_alloc}(hjBhhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMrhj>ubjW)}(hhh]h)}(hFis incremented every time a shmem huge page is successfully allocated.h]hFis incremented every time a shmem huge page is successfully allocated.}(hjShhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMqhjPubah}(h]h ]h"]h$]h&]uh1jVhj>ubeh}(h]h ]h"]h$]h&]uh1j@hhhMrhjhhubjA)}(hshmem_fallback is incremented if a shmem huge page is attempted to be allocated but fails and instead falls back to using small pages. h](jG)}(hshmem_fallbackh]hshmem_fallback}(hjqhhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMvhjmubjW)}(hhh]h)}(hwis incremented if a shmem huge page is attempted to be allocated but fails and instead falls back to using small pages.h]hwis incremented if a shmem huge page is attempted to be allocated but fails and instead falls back to using small pages.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMuhjubah}(h]h ]h"]h$]h&]uh1jVhjmubeh}(h]h ]h"]h$]h&]uh1j@hhhMvhjhhubjA)}(hshmem_fallback_charge is incremented if a shmem huge page cannot be charged and instead falls back to using small pages even though the allocation was successful. h](jG)}(hshmem_fallback_chargeh]hshmem_fallback_charge}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhM{hjubjW)}(hhh]h)}(his incremented if a shmem huge page cannot be charged and instead falls back to using small pages even though the allocation was successful.h]his incremented if a shmem huge page cannot be charged and instead falls back to using small pages even though the allocation was successful.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMyhjubah}(h]h ]h"]h$]h&]uh1jVhjubeh}(h]h ]h"]h$]h&]uh1j@hhhM{hjhhubjA)}(hsplit is incremented every time a huge page is successfully split into smaller orders. This can happen for a variety of reasons but a common reason is that a huge page is old and is being reclaimed. h](jG)}(hsplith]hsplit}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMhjubjW)}(hhh]h)}(his incremented every time a huge page is successfully split into smaller orders. This can happen for a variety of reasons but a common reason is that a huge page is old and is being reclaimed.h]his incremented every time a huge page is successfully split into smaller orders. This can happen for a variety of reasons but a common reason is that a huge page is old and is being reclaimed.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM~hjubah}(h]h ]h"]h$]h&]uh1jVhjubeh}(h]h ]h"]h$]h&]uh1j@hhhMhjhhubjA)}(htsplit_failed is incremented if kernel fails to split huge page. This can happen if the page was pinned by somebody. h](jG)}(h split_failedh]h split_failed}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMhjubjW)}(hhh]h)}(hfis incremented if kernel fails to split huge page. This can happen if the page was pinned by somebody.h]hfis incremented if kernel fails to split huge page. This can happen if the page was pinned by somebody.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jVhjubeh}(h]h ]h"]h$]h&]uh1j@hhhMhjhhubjA)}(hXsplit_deferred is incremented when a huge page is put onto split queue. This happens when a huge page is partially unmapped and splitting it would free up some memory. Pages on split queue are going to be split under memory pressure, if splitting is possible. h](jG)}(hsplit_deferredh]hsplit_deferred}(hj-hhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMhj)ubjW)}(hhh]h)}(his incremented when a huge page is put onto split queue. This happens when a huge page is partially unmapped and splitting it would free up some memory. Pages on split queue are going to be split under memory pressure, if splitting is possible.h]his incremented when a huge page is put onto split queue. This happens when a huge page is partially unmapped and splitting it would free up some memory. Pages on split queue are going to be split under memory pressure, if splitting is possible.}(hj>hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj;ubah}(h]h ]h"]h$]h&]uh1jVhj)ubeh}(h]h ]h"]h$]h&]uh1j@hhhMhjhhubjA)}(hnr_anon the number of anonymous THP we have in the whole system. These THPs might be currently entirely mapped or have partially unmapped/unused subpages. h](jG)}(hnr_anonh]hnr_anon}(hj\hhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMhjXubjW)}(hhh]h)}(hthe number of anonymous THP we have in the whole system. These THPs might be currently entirely mapped or have partially unmapped/unused subpages.h]hthe number of anonymous THP we have in the whole system. These THPs might be currently entirely mapped or have partially unmapped/unused subpages.}(hjmhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjjubah}(h]h ]h"]h$]h&]uh1jVhjXubeh}(h]h ]h"]h$]h&]uh1j@hhhMhjhhubjA)}(hXcnr_anon_partially_mapped the number of anonymous THP which are likely partially mapped, possibly wasting memory, and have been queued for deferred memory reclamation. Note that in corner some cases (e.g., failed migration), we might detect an anonymous THP as "partially mapped" and count it here, even though it is not actually partially mapped anymore. h](jG)}(hnr_anon_partially_mappedh]hnr_anon_partially_mapped}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMhjubjW)}(hhh]h)}(hXIthe number of anonymous THP which are likely partially mapped, possibly wasting memory, and have been queued for deferred memory reclamation. Note that in corner some cases (e.g., failed migration), we might detect an anonymous THP as "partially mapped" and count it here, even though it is not actually partially mapped anymore.h]hXMthe number of anonymous THP which are likely partially mapped, possibly wasting memory, and have been queued for deferred memory reclamation. Note that in corner some cases (e.g., failed migration), we might detect an anonymous THP as “partially mapped” and count it here, even though it is not actually partially mapped anymore.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1jVhjubeh}(h]h ]h"]h$]h&]uh1j@hhhMhjhhubeh}(h]h ]h"]h$]h&]uh1j;hjhhhhhNubh)}(hAs the system ages, allocating huge pages may be expensive as the system uses memory compaction to copy data around memory to free a huge page for use. There are some counters in ``/proc/vmstat`` to help monitor this overhead.h](hAs the system ages, allocating huge pages may be expensive as the system uses memory compaction to copy data around memory to free a huge page for use. There are some counters in }(hjhhhNhNubjg)}(h``/proc/vmstat``h]h /proc/vmstat}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjubh to help monitor this overhead.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjhhubj<)}(hhh](jA)}(hwcompact_stall is incremented every time a process stalls to run memory compaction so that a huge page is free for use. h](jG)}(h compact_stallh]h compact_stall}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMhjubjW)}(hhh]h)}(hhis incremented every time a process stalls to run memory compaction so that a huge page is free for use.h]hhis incremented every time a process stalls to run memory compaction so that a huge page is free for use.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1jVhjubeh}(h]h ]h"]h$]h&]uh1j@hhhMhjubjA)}(h]compact_success is incremented if the system compacted memory and freed a huge page for use. h](jG)}(hcompact_successh]hcompact_success}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMhjubjW)}(hhh]h)}(hLis incremented if the system compacted memory and freed a huge page for use.h]hLis incremented if the system compacted memory and freed a huge page for use.}(hj#hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jVhjubeh}(h]h ]h"]h$]h&]uh1j@hhhMhjhhubjA)}(hNcompact_fail is incremented if the system tries to compact memory but failed. h](jG)}(h compact_failh]h compact_fail}(hjAhhhNhNubah}(h]h ]h"]h$]h&]uh1jFhhhMhj=ubjW)}(hhh]h)}(h@is incremented if the system tries to compact memory but failed.h]h@is incremented if the system tries to compact memory but failed.}(hjRhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjOubah}(h]h ]h"]h$]h&]uh1jVhj=ubeh}(h]h ]h"]h$]h&]uh1j@hhhMhjhhubeh}(h]h ]h"]h$]h&]uh1j;hjhhhhhNubh)}(hIt is possible to establish how long the stalls were using the function tracer to record how long was spent in __alloc_pages() and using the mm_page_alloc tracepoint to identify which allocations were for huge pages.h]hIt is possible to establish how long the stalls were using the function tracer to record how long was spent in __alloc_pages() and using the mm_page_alloc tracepoint to identify which allocations were for huge pages.}(hjrhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubeh}(h]monitoring-usageah ]h"]monitoring usageah$]h&]uh1hhhhhhhhMubh)}(hhh](h)}(hOptimizing the applicationsh]hOptimizing the applications}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMubh)}(hTo be guaranteed that the kernel will map a THP immediately in any memory region, the mmap region has to be hugepage naturally aligned. posix_memalign() can provide that guarantee.h]hTo be guaranteed that the kernel will map a THP immediately in any memory region, the mmap region has to be hugepage naturally aligned. posix_memalign() can provide that guarantee.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubeh}(h]optimizing-the-applicationsah ]h"]optimizing the applicationsah$]h&]uh1hhhhhhhhMubh)}(hhh](h)}(h Hugetlbfsh]h Hugetlbfs}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMubh)}(hX4You can use hugetlbfs on a kernel that has transparent hugepage support enabled just fine as always. No difference can be noted in hugetlbfs other than there will be less overall fragmentation. All usual features belonging to hugetlbfs are preserved and unaffected. libhugetlbfs will also work fine as usual.h]hX4You can use hugetlbfs on a kernel that has transparent hugepage support enabled just fine as always. No difference can be noted in hugetlbfs other than there will be less overall fragmentation. All usual features belonging to hugetlbfs are preserved and unaffected. libhugetlbfs will also work fine as usual.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubeh}(h] hugetlbfsah ]h"] hugetlbfsah$]h&]uh1hhhhhhhhMubeh}(h]transparent-hugepage-supportah ]h"]transparent hugepage supportah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksentryfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerjerror_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}j ]jasnameids}(jjjj j^j j]jZjjjUjRj j jbj_j j jZjWjjjjjjjju nametypes}(jjj^j]jjUj jbj jZjjjjuh}(jhj hj jjZjjj$jRjj jej_j j j jWj jjejjjjjju footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages]transform_messages]hsystem_message)}(hhh]h)}(hhh]h/Hyperlink target "thp-sysfs" is not referenced.}hjksbah}(h]h ]h"]h$]h&]uh1hhjhubah}(h]h ]h"]h$]h&]levelKtypeINFOsourcehlineKfuh1jfuba transformerN include_log] decorationNhhub.