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
collapse_pte_mapped_thp(struct mm_struct * mm,unsigned long addr,bool install_pmd)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
khugepaged_fork(struct mm_struct * mm,struct mm_struct * oldmm)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
khugepaged_exit(struct mm_struct * mm)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 */
khugepaged_fork(struct mm_struct * mm,struct mm_struct * oldmm)43 static inline void khugepaged_fork(struct mm_struct *mm, struct mm_struct *oldmm)
44 {
45 }
khugepaged_exit(struct mm_struct * mm)46 static inline void khugepaged_exit(struct mm_struct *mm)
47 {
48 }
khugepaged_enter_vma(struct vm_area_struct * vma,unsigned long vm_flags)49 static inline void khugepaged_enter_vma(struct vm_area_struct *vma,
50 unsigned long vm_flags)
51 {
52 }
collapse_pte_mapped_thp(struct mm_struct * mm,unsigned long addr,bool install_pmd)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
khugepaged_min_free_kbytes_update(void)59 static inline void khugepaged_min_free_kbytes_update(void)
60 {
61 }
62
current_is_khugepaged(void)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