From: Qi Zheng Introduce the VM_RESERVED_THP VMA flag to mark Virtual Memory Areas (VMAs) that have the reserved THP policy enabled. Also, add the "rt" (reserved THP) flag indicator to the output of /proc//smaps to facilitate monitoring and debugging the status of the corresponding VMAs from userspace. Signed-off-by: Qi Zheng --- fs/proc/task_mmu.c | 3 +++ include/linux/mm.h | 7 +++++++ tools/testing/vma/include/dup.h | 1 + 3 files changed, 11 insertions(+) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index d32408f7cd5ed..65c4b2a61aeac 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1245,6 +1245,9 @@ static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma) #endif #ifdef CONFIG_64BIT [ilog2(VM_SEALED)] = "sl", +#endif +#ifdef CONFIG_TRANSPARENT_HUGEPAGE + [ilog2(VM_RESERVED_THP)] = "rt", #endif }; size_t i; diff --git a/include/linux/mm.h b/include/linux/mm.h index 485df9c2dbddb..278cf4bfd4ec5 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -353,6 +353,7 @@ enum { #endif DECLARE_VMA_BIT(UFFD_MINOR, 41), DECLARE_VMA_BIT(SEALED, 42), + DECLARE_VMA_BIT(RESERVED_THP, 43), /* Flags that reuse flags above. */ DECLARE_VMA_BIT_ALIAS(PKEY_BIT0, HIGH_ARCH_0), DECLARE_VMA_BIT_ALIAS(PKEY_BIT1, HIGH_ARCH_1), @@ -526,6 +527,12 @@ enum { #define VMA_DROPPABLE EMPTY_VMA_FLAGS #endif +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +#define VM_RESERVED_THP INIT_VM_FLAG(RESERVED_THP) +#else +#define VM_RESERVED_THP VM_NONE +#endif + /* Bits set in the VMA until the stack is in its final location */ #define VM_STACK_INCOMPLETE_SETUP (VM_RAND_READ | VM_SEQ_READ | VM_STACK_EARLY) diff --git a/tools/testing/vma/include/dup.h b/tools/testing/vma/include/dup.h index cf73bcd9bb9d5..022b7a56b6a9f 100644 --- a/tools/testing/vma/include/dup.h +++ b/tools/testing/vma/include/dup.h @@ -160,6 +160,7 @@ enum { #endif DECLARE_VMA_BIT(UFFD_MINOR, 41), DECLARE_VMA_BIT(SEALED, 42), + DECLARE_VMA_BIT(RESERVED_THP, 43), /* Flags that reuse flags above. */ DECLARE_VMA_BIT_ALIAS(PKEY_BIT0, HIGH_ARCH_0), DECLARE_VMA_BIT_ALIAS(PKEY_BIT1, HIGH_ARCH_1), -- 2.54.0