2011-01-14 07:46:58 +08:00
|
|
|
#ifndef _LINUX_KHUGEPAGED_H
|
|
|
|
#define _LINUX_KHUGEPAGED_H
|
|
|
|
|
2017-02-09 01:51:30 +08:00
|
|
|
#include <linux/sched/coredump.h> /* MMF_VM_HUGEPAGE */
|
|
|
|
|
2011-01-14 07:46:58 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
|
2016-07-27 06:26:24 +08:00
|
|
|
extern struct attribute_group khugepaged_attr_group;
|
|
|
|
|
|
|
|
extern int khugepaged_init(void);
|
|
|
|
extern void khugepaged_destroy(void);
|
|
|
|
extern int start_stop_khugepaged(void);
|
2011-01-14 07:46:58 +08:00
|
|
|
extern int __khugepaged_enter(struct mm_struct *mm);
|
|
|
|
extern void __khugepaged_exit(struct mm_struct *mm);
|
2014-10-30 05:50:31 +08:00
|
|
|
extern int khugepaged_enter_vma_merge(struct vm_area_struct *vma,
|
|
|
|
unsigned long vm_flags);
|
2011-01-14 07:46:58 +08:00
|
|
|
|
|
|
|
#define khugepaged_enabled() \
|
|
|
|
(transparent_hugepage_flags & \
|
|
|
|
((1<<TRANSPARENT_HUGEPAGE_FLAG) | \
|
|
|
|
(1<<TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG)))
|
|
|
|
#define khugepaged_always() \
|
|
|
|
(transparent_hugepage_flags & \
|
|
|
|
(1<<TRANSPARENT_HUGEPAGE_FLAG))
|
|
|
|
#define khugepaged_req_madv() \
|
|
|
|
(transparent_hugepage_flags & \
|
|
|
|
(1<<TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG))
|
|
|
|
#define khugepaged_defrag() \
|
|
|
|
(transparent_hugepage_flags & \
|
|
|
|
(1<<TRANSPARENT_HUGEPAGE_DEFRAG_KHUGEPAGED_FLAG))
|
|
|
|
|
|
|
|
static inline int khugepaged_fork(struct mm_struct *mm, struct mm_struct *oldmm)
|
|
|
|
{
|
|
|
|
if (test_bit(MMF_VM_HUGEPAGE, &oldmm->flags))
|
|
|
|
return __khugepaged_enter(mm);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void khugepaged_exit(struct mm_struct *mm)
|
|
|
|
{
|
|
|
|
if (test_bit(MMF_VM_HUGEPAGE, &mm->flags))
|
|
|
|
__khugepaged_exit(mm);
|
|
|
|
}
|
|
|
|
|
2014-10-30 05:50:31 +08:00
|
|
|
static inline int khugepaged_enter(struct vm_area_struct *vma,
|
|
|
|
unsigned long vm_flags)
|
2011-01-14 07:46:58 +08:00
|
|
|
{
|
|
|
|
if (!test_bit(MMF_VM_HUGEPAGE, &vma->vm_mm->flags))
|
2011-01-14 07:47:17 +08:00
|
|
|
if ((khugepaged_always() ||
|
2014-10-30 05:50:31 +08:00
|
|
|
(khugepaged_req_madv() && (vm_flags & VM_HUGEPAGE))) &&
|
2017-07-11 06:48:02 +08:00
|
|
|
!(vm_flags & VM_NOHUGEPAGE) &&
|
|
|
|
!test_bit(MMF_DISABLE_THP, &vma->vm_mm->flags))
|
2011-01-14 07:46:58 +08:00
|
|
|
if (__khugepaged_enter(vma->vm_mm))
|
|
|
|
return -ENOMEM;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#else /* CONFIG_TRANSPARENT_HUGEPAGE */
|
|
|
|
static inline int khugepaged_fork(struct mm_struct *mm, struct mm_struct *oldmm)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static inline void khugepaged_exit(struct mm_struct *mm)
|
|
|
|
{
|
|
|
|
}
|
2014-10-30 05:50:31 +08:00
|
|
|
static inline int khugepaged_enter(struct vm_area_struct *vma,
|
|
|
|
unsigned long vm_flags)
|
2011-01-14 07:46:58 +08:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2014-10-30 05:50:31 +08:00
|
|
|
static inline int khugepaged_enter_vma_merge(struct vm_area_struct *vma,
|
|
|
|
unsigned long vm_flags)
|
2011-01-14 07:46:58 +08:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
|
|
|
|
|
|
|
|
#endif /* _LINUX_KHUGEPAGED_H */
|