linux/include/linux/khugepaged.h
<<
>>
Prefs
   1#ifndef _LINUX_KHUGEPAGED_H
   2#define _LINUX_KHUGEPAGED_H
   3
   4#include <linux/sched.h> /* MMF_VM_HUGEPAGE */
   5
   6#ifdef CONFIG_TRANSPARENT_HUGEPAGE
   7extern struct attribute_group khugepaged_attr_group;
   8
   9extern int khugepaged_init(void);
  10extern void khugepaged_destroy(void);
  11extern int start_stop_khugepaged(void);
  12extern int __khugepaged_enter(struct mm_struct *mm);
  13extern void __khugepaged_exit(struct mm_struct *mm);
  14extern int khugepaged_enter_vma_merge(struct vm_area_struct *vma,
  15                                      unsigned long vm_flags);
  16
  17#define khugepaged_enabled()                                           \
  18        (transparent_hugepage_flags &                                  \
  19         ((1<<TRANSPARENT_HUGEPAGE_FLAG) |                     \
  20          (1<<TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG)))
  21#define khugepaged_always()                             \
  22        (transparent_hugepage_flags &                   \
  23         (1<<TRANSPARENT_HUGEPAGE_FLAG))
  24#define khugepaged_req_madv()                                   \
  25        (transparent_hugepage_flags &                           \
  26         (1<<TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG))
  27#define khugepaged_defrag()                                     \
  28        (transparent_hugepage_flags &                           \
  29         (1<<TRANSPARENT_HUGEPAGE_DEFRAG_KHUGEPAGED_FLAG))
  30
  31static inline int khugepaged_fork(struct mm_struct *mm, struct mm_struct *oldmm)
  32{
  33        if (test_bit(MMF_VM_HUGEPAGE, &oldmm->flags))
  34                return __khugepaged_enter(mm);
  35        return 0;
  36}
  37
  38static inline void khugepaged_exit(struct mm_struct *mm)
  39{
  40        if (test_bit(MMF_VM_HUGEPAGE, &mm->flags))
  41                __khugepaged_exit(mm);
  42}
  43
  44static inline int khugepaged_enter(struct vm_area_struct *vma,
  45                                   unsigned long vm_flags)
  46{
  47        if (!test_bit(MMF_VM_HUGEPAGE, &vma->vm_mm->flags))
  48                if ((khugepaged_always() ||
  49                     (khugepaged_req_madv() && (vm_flags & VM_HUGEPAGE))) &&
  50                    !(vm_flags & VM_NOHUGEPAGE))
  51                        if (__khugepaged_enter(vma->vm_mm))
  52                                return -ENOMEM;
  53        return 0;
  54}
  55#else /* CONFIG_TRANSPARENT_HUGEPAGE */
  56static inline int khugepaged_fork(struct mm_struct *mm, struct mm_struct *oldmm)
  57{
  58        return 0;
  59}
  60static inline void khugepaged_exit(struct mm_struct *mm)
  61{
  62}
  63static inline int khugepaged_enter(struct vm_area_struct *vma,
  64                                   unsigned long vm_flags)
  65{
  66        return 0;
  67}
  68static inline int khugepaged_enter_vma_merge(struct vm_area_struct *vma,
  69                                             unsigned long vm_flags)
  70{
  71        return 0;
  72}
  73#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
  74
  75#endif /* _LINUX_KHUGEPAGED_H */
  76