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 extern unsigned int khugepaged_max_ptes_none __read_mostly; 8 #ifdef CONFIG_TRANSPARENT_HUGEPAGE 9 extern struct attribute_group khugepaged_attr_group; 10 11 extern int khugepaged_init(void); 12 extern void khugepaged_destroy(void); 13 extern int start_stop_khugepaged(void); 14 extern void __khugepaged_enter(struct mm_struct *mm); 15 extern void __khugepaged_exit(struct mm_struct *mm); 16 extern void khugepaged_enter_vma(struct vm_area_struct *vma, 17 unsigned long vm_flags); 18 extern void khugepaged_min_free_kbytes_update(void); 19 extern bool current_is_khugepaged(void); 20 #ifdef CONFIG_SHMEM 21 extern int collapse_pte_mapped_thp(struct mm_struct *mm, unsigned long addr, 22 bool install_pmd); 23 #else 24 static inline int collapse_pte_mapped_thp(struct mm_struct *mm, 25 unsigned long addr, bool install_pmd) 26 { 27 return 0; 28 } 29 #endif 30 31 static inline void khugepaged_fork(struct mm_struct *mm, struct mm_struct *oldmm) 32 { 33 if (test_bit(MMF_VM_HUGEPAGE, &oldmm->flags)) 34 __khugepaged_enter(mm); 35 } 36 37 static inline void khugepaged_exit(struct mm_struct *mm) 38 { 39 if (test_bit(MMF_VM_HUGEPAGE, &mm->flags)) 40 __khugepaged_exit(mm); 41 } 42 #else /* CONFIG_TRANSPARENT_HUGEPAGE */ 43 static inline void khugepaged_fork(struct mm_struct *mm, struct mm_struct *oldmm) 44 { 45 } 46 static inline void khugepaged_exit(struct mm_struct *mm) 47 { 48 } 49 static inline void khugepaged_enter_vma(struct vm_area_struct *vma, 50 unsigned long vm_flags) 51 { 52 } 53 static inline int collapse_pte_mapped_thp(struct mm_struct *mm, 54 unsigned long addr, bool install_pmd) 55 { 56 return 0; 57 } 58 59 static inline void khugepaged_min_free_kbytes_update(void) 60 { 61 } 62 63 static inline bool current_is_khugepaged(void) 64 { 65 return false; 66 } 67 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ 68 69 #endif /* _LINUX_KHUGEPAGED_H */ 70