Report deactivated anonymous pages in PAGEMAP_SCAN results. Only set on anonymous VMAs (shmem cold = !PAGE_IS_PRESENT). Both PTE and PMD (THP) levels handled.
Signed-off-by: Kiryl Shutsemau (Meta) <[email protected]> Assisted-by: Claude:claude-opus-4-6 --- fs/proc/task_mmu.c | 11 ++++++++++- include/uapi/linux/fs.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index e091931d7ca1..fc42cfd5720a 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -2329,7 +2329,7 @@ static int pagemap_release(struct inode *inode, struct file *file) PAGE_IS_FILE | PAGE_IS_PRESENT | \ PAGE_IS_SWAPPED | PAGE_IS_PFNZERO | \ PAGE_IS_HUGE | PAGE_IS_SOFT_DIRTY | \ - PAGE_IS_GUARD) + PAGE_IS_GUARD | PAGE_IS_UFFD_DEACTIVATED) #define PM_SCAN_FLAGS (PM_SCAN_WP_MATCHING | PM_SCAN_CHECK_WPASYNC) struct pagemap_scan_private { @@ -2354,6 +2354,10 @@ static unsigned long pagemap_page_category(struct pagemap_scan_private *p, categories = PAGE_IS_PRESENT; + if (pte_protnone(pte) && vma_is_accessible(vma) && + vma_is_anonymous(vma) && userfaultfd_minor(vma)) + categories |= PAGE_IS_UFFD_DEACTIVATED; + if (!pte_uffd_wp(pte)) categories |= PAGE_IS_WRITTEN; @@ -2422,6 +2426,11 @@ static unsigned long pagemap_thp_category(struct pagemap_scan_private *p, struct page *page; categories |= PAGE_IS_PRESENT; + + if (pmd_protnone(pmd) && vma_is_accessible(vma) && + vma_is_anonymous(vma) && userfaultfd_minor(vma)) + categories |= PAGE_IS_UFFD_DEACTIVATED; + if (!pmd_uffd_wp(pmd)) categories |= PAGE_IS_WRITTEN; diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h index 70b2b661f42c..af5b28901800 100644 --- a/include/uapi/linux/fs.h +++ b/include/uapi/linux/fs.h @@ -455,6 +455,7 @@ typedef int __bitwise __kernel_rwf_t; #define PAGE_IS_HUGE (1 << 6) #define PAGE_IS_SOFT_DIRTY (1 << 7) #define PAGE_IS_GUARD (1 << 8) +#define PAGE_IS_UFFD_DEACTIVATED (1 << 9) /* * struct page_region - Page region with flags -- 2.51.2

