khugepaged.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _LINUX_KHUGEPAGED_H
  3. #define _LINUX_KHUGEPAGED_H
  4. #include <linux/sched/coredump.h> /* MMF_VM_HUGEPAGE */
  5. #ifdef CONFIG_TRANSPARENT_HUGEPAGE
  6. extern struct attribute_group khugepaged_attr_group;
  7. extern int khugepaged_init(void);
  8. extern void khugepaged_destroy(void);
  9. extern int start_stop_khugepaged(void);
  10. extern void __khugepaged_enter(struct mm_struct *mm);
  11. extern void __khugepaged_exit(struct mm_struct *mm);
  12. extern void khugepaged_enter_vma(struct vm_area_struct *vma,
  13. unsigned long vm_flags);
  14. extern void khugepaged_min_free_kbytes_update(void);
  15. #ifdef CONFIG_SHMEM
  16. extern int collapse_pte_mapped_thp(struct mm_struct *mm, unsigned long addr,
  17. bool install_pmd);
  18. #else
  19. static inline int collapse_pte_mapped_thp(struct mm_struct *mm,
  20. unsigned long addr, bool install_pmd)
  21. {
  22. return 0;
  23. }
  24. #endif
  25. static inline void khugepaged_fork(struct mm_struct *mm, struct mm_struct *oldmm)
  26. {
  27. if (test_bit(MMF_VM_HUGEPAGE, &oldmm->flags))
  28. __khugepaged_enter(mm);
  29. }
  30. static inline void khugepaged_exit(struct mm_struct *mm)
  31. {
  32. if (test_bit(MMF_VM_HUGEPAGE, &mm->flags))
  33. __khugepaged_exit(mm);
  34. }
  35. #else /* CONFIG_TRANSPARENT_HUGEPAGE */
  36. static inline void khugepaged_fork(struct mm_struct *mm, struct mm_struct *oldmm)
  37. {
  38. }
  39. static inline void khugepaged_exit(struct mm_struct *mm)
  40. {
  41. }
  42. static inline void khugepaged_enter_vma(struct vm_area_struct *vma,
  43. unsigned long vm_flags)
  44. {
  45. }
  46. static inline int collapse_pte_mapped_thp(struct mm_struct *mm,
  47. unsigned long addr, bool install_pmd)
  48. {
  49. return 0;
  50. }
  51. static inline void khugepaged_min_free_kbytes_update(void)
  52. {
  53. }
  54. #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
  55. #endif /* _LINUX_KHUGEPAGED_H */