69 lines
1.8 KiB
C
Raw Normal View History

2026-01-21 18:59:54 +08:00
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _LINUX_KHUGEPAGED_H
#define _LINUX_KHUGEPAGED_H
#include <linux/sched/coredump.h> /* MMF_VM_HUGEPAGE */
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
extern struct attribute_group khugepaged_attr_group;
extern int khugepaged_init(void);
extern void khugepaged_destroy(void);
extern int start_stop_khugepaged(void);
2026-01-29 22:25:33 +08:00
extern void __khugepaged_enter(struct mm_struct *mm);
2026-01-21 18:59:54 +08:00
extern void __khugepaged_exit(struct mm_struct *mm);
2026-01-29 22:25:33 +08:00
extern void khugepaged_enter_vma(struct vm_area_struct *vma,
unsigned long vm_flags);
2026-01-21 18:59:54 +08:00
extern void khugepaged_min_free_kbytes_update(void);
2026-01-29 22:25:33 +08:00
extern bool current_is_khugepaged(void);
2026-01-21 18:59:54 +08:00
#ifdef CONFIG_SHMEM
2026-01-29 22:25:33 +08:00
extern int collapse_pte_mapped_thp(struct mm_struct *mm, unsigned long addr,
bool install_pmd);
2026-01-21 18:59:54 +08:00
#else
2026-01-29 22:25:33 +08:00
static inline int collapse_pte_mapped_thp(struct mm_struct *mm,
unsigned long addr, bool install_pmd)
2026-01-21 18:59:54 +08:00
{
2026-01-29 22:25:33 +08:00
return 0;
2026-01-21 18:59:54 +08:00
}
#endif
2026-01-29 22:25:33 +08:00
static inline void khugepaged_fork(struct mm_struct *mm, struct mm_struct *oldmm)
2026-01-21 18:59:54 +08:00
{
if (test_bit(MMF_VM_HUGEPAGE, &oldmm->flags))
2026-01-29 22:25:33 +08:00
__khugepaged_enter(mm);
2026-01-21 18:59:54 +08:00
}
static inline void khugepaged_exit(struct mm_struct *mm)
{
if (test_bit(MMF_VM_HUGEPAGE, &mm->flags))
__khugepaged_exit(mm);
}
#else /* CONFIG_TRANSPARENT_HUGEPAGE */
2026-01-29 22:25:33 +08:00
static inline void khugepaged_fork(struct mm_struct *mm, struct mm_struct *oldmm)
2026-01-21 18:59:54 +08:00
{
}
static inline void khugepaged_exit(struct mm_struct *mm)
{
}
2026-01-29 22:25:33 +08:00
static inline void khugepaged_enter_vma(struct vm_area_struct *vma,
unsigned long vm_flags)
2026-01-21 18:59:54 +08:00
{
}
2026-01-29 22:25:33 +08:00
static inline int collapse_pte_mapped_thp(struct mm_struct *mm,
unsigned long addr, bool install_pmd)
2026-01-21 18:59:54 +08:00
{
return 0;
}
2026-01-29 22:25:33 +08:00
static inline void khugepaged_min_free_kbytes_update(void)
2026-01-21 18:59:54 +08:00
{
}
2026-01-29 22:25:33 +08:00
static inline bool current_is_khugepaged(void)
2026-01-21 18:59:54 +08:00
{
2026-01-29 22:25:33 +08:00
return false;
2026-01-21 18:59:54 +08:00
}
#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
#endif /* _LINUX_KHUGEPAGED_H */