1 #ifndef _LINUX_KHUGEPAGED_H
2 #define _LINUX_KHUGEPAGED_H
4 #include <linux/sched/coredump.h> /* MMF_VM_HUGEPAGE */
7 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
8 extern struct attribute_group khugepaged_attr_group
;
10 extern int khugepaged_init(void);
11 extern void khugepaged_destroy(void);
12 extern int start_stop_khugepaged(void);
13 extern int __khugepaged_enter(struct mm_struct
*mm
);
14 extern void __khugepaged_exit(struct mm_struct
*mm
);
15 extern int khugepaged_enter_vma_merge(struct vm_area_struct
*vma
,
16 unsigned long vm_flags
);
18 #define khugepaged_enabled() \
19 (transparent_hugepage_flags & \
20 ((1<<TRANSPARENT_HUGEPAGE_FLAG) | \
21 (1<<TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG)))
22 #define khugepaged_always() \
23 (transparent_hugepage_flags & \
24 (1<<TRANSPARENT_HUGEPAGE_FLAG))
25 #define khugepaged_req_madv() \
26 (transparent_hugepage_flags & \
27 (1<<TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG))
28 #define khugepaged_defrag() \
29 (transparent_hugepage_flags & \
30 (1<<TRANSPARENT_HUGEPAGE_DEFRAG_KHUGEPAGED_FLAG))
32 static inline int khugepaged_fork(struct mm_struct
*mm
, struct mm_struct
*oldmm
)
34 if (test_bit(MMF_VM_HUGEPAGE
, &oldmm
->flags
))
35 return __khugepaged_enter(mm
);
39 static inline void khugepaged_exit(struct mm_struct
*mm
)
41 if (test_bit(MMF_VM_HUGEPAGE
, &mm
->flags
))
42 __khugepaged_exit(mm
);
45 static inline int khugepaged_enter(struct vm_area_struct
*vma
,
46 unsigned long vm_flags
)
48 if (!test_bit(MMF_VM_HUGEPAGE
, &vma
->vm_mm
->flags
))
49 if ((khugepaged_always() ||
50 (khugepaged_req_madv() && (vm_flags
& VM_HUGEPAGE
))) &&
51 !(vm_flags
& VM_NOHUGEPAGE
) &&
52 !test_bit(MMF_DISABLE_THP
, &vma
->vm_mm
->flags
))
53 if (__khugepaged_enter(vma
->vm_mm
))
57 #else /* CONFIG_TRANSPARENT_HUGEPAGE */
58 static inline int khugepaged_fork(struct mm_struct
*mm
, struct mm_struct
*oldmm
)
62 static inline void khugepaged_exit(struct mm_struct
*mm
)
65 static inline int khugepaged_enter(struct vm_area_struct
*vma
,
66 unsigned long vm_flags
)
70 static inline int khugepaged_enter_vma_merge(struct vm_area_struct
*vma
,
71 unsigned long vm_flags
)
75 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
77 #endif /* _LINUX_KHUGEPAGED_H */