1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _LINUX_KHUGEPAGED_H 3 #define _LINUX_KHUGEPAGED_H 4 5 #include <linux/sched/coredump.h> /* MMF_VM_HUGEPAGE */ 6 7 #ifdef CONFIG_TRANSPARENT_HUGEPAGE 8 extern struct attribute_group khugepaged_attr_group; 9 10 extern int khugepaged_init(void); 11 extern void khugepaged_destroy(void); 12 extern int start_stop_khugepaged(void); 13 extern void __khugepaged_enter(struct mm_struct *mm); 14 extern void __khugepaged_exit(struct mm_struct *mm); 15 extern void khugepaged_enter_vma(struct vm_area_struct *vma, 16 unsigned long vm_flags); 17 extern void khugepaged_min_free_kbytes_update(void); 18 #ifdef CONFIG_SHMEM 19 extern int collapse_pte_mapped_thp(struct mm_struct *mm, unsigned long addr, 20 bool install_pmd); 21 #else 22 static inline int collapse_pte_mapped_thp(struct mm_struct *mm, 23 unsigned long addr, bool install_pmd) 24 { 25 return 0; 26 } 27 #endif 28 29 static inline void khugepaged_fork(struct mm_struct *mm, struct mm_struct *oldmm) 30 { 31 if (test_bit(MMF_VM_HUGEPAGE, &oldmm->flags)) 32 __khugepaged_enter(mm); 33 } 34 35 static inline void khugepaged_exit(struct mm_struct *mm) 36 { 37 if (test_bit(MMF_VM_HUGEPAGE, &mm->flags)) 38 __khugepaged_exit(mm); 39 } 40 #else /* CONFIG_TRANSPARENT_HUGEPAGE */ 41 static inline void khugepaged_fork(struct mm_struct *mm, struct mm_struct *oldmm) 42 { 43 } 44 static inline void khugepaged_exit(struct mm_struct *mm) 45 { 46 } 47 static inline void khugepaged_enter_vma(struct vm_area_struct *vma, 48 unsigned long vm_flags) 49 { 50 } 51 static inline int collapse_pte_mapped_thp(struct mm_struct *mm, 52 unsigned long addr, bool install_pmd) 53 { 54 return 0; 55 } 56 57 static inline void khugepaged_min_free_kbytes_update(void) 58 { 59 } 60 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ 61 62 #endif /* _LINUX_KHUGEPAGED_H */ 63