Add the documentation. Signed-off-by: Yafang Shao <laoar.shao@xxxxxxxxx> --- Documentation/admin-guide/mm/transhuge.rst | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/Documentation/admin-guide/mm/transhuge.rst b/Documentation/admin-guide/mm/transhuge.rst index 1654211cc6cf..1e072eaacf65 100644 --- a/Documentation/admin-guide/mm/transhuge.rst +++ b/Documentation/admin-guide/mm/transhuge.rst @@ -738,3 +738,49 @@ 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. + +BPF-based THP adjustment +======================== + +Overview +-------- + +When the system is configured with "always" or "madvise" THP mode, a BPF program +can be used to adjust THP allocation policies dynamically. This enables +fine-grained control over THP decisions based on various factors including +workload identity, allocation context, and system memory pressure. + +Program Interface +----------------- + +This feature implements a struct_ops BPF program with the following interface:: + + int thp_get_order(struct vm_area_struct *vma, + enum bpf_thp_vma_type vma_type, + enum tva_type tva_type, + unsigned long orders); + +Parameters:: + + @vma: vm_area_struct associated with the THP allocation + @vma_type: The VMA type, such as BPF_THP_VM_HUGEPAGE if VM_HUGEPAGE is set + BPF_THP_VM_NOHUGEPAGE if VM_NOHUGEPAGE is set, or BPF_THP_VM_NONE + if neither is set. + @tva_type: TVA type for current @vma + @orders: Bitmask of requested THP orders for this allocation + - PMD-mapped allocation if PMD_ORDER is set + - mTHP allocation otherwise + +Return value:: + + The suggested THP order from the BPF program for allocation. It will not + exceed the highest requested order in @orders. Return -1 to indicate that the + original requested @orders should remain unchanged. + +Implementation Notes +-------------------- + +This is currently an experimental feature. +CONFIG_BPF_GET_THP_ORDER must be enabled to use it. +Only one BPF program can be attached at a time, but the program can be updated +dynamically to adjust policies without requiring affected tasks to be restarted. -- 2.47.3