Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fs/proc: extend the PAGEMAP_SCAN ioctl to report guard regions

Patch series "fs/proc: extend the PAGEMAP_SCAN ioctl to report guard
regions", v2.

Introduce the PAGE_IS_GUARD flag in the PAGEMAP_SCAN ioctl to expose
information about guard regions. This allows userspace tools, such as
CRIU, to detect and handle guard regions.

Currently, CRIU utilizes PAGEMAP_SCAN as a more efficient alternative to
parsing /proc/pid/pagemap. Without this change, guard regions are
incorrectly reported as swap-anon regions, leading CRIU to attempt dumping
them and subsequently failing.

The series includes updates to the documentation and selftests to reflect
the new functionality.


This patch (of 3):

Introduce the PAGE_IS_GUARD flag in the PAGEMAP_SCAN ioctl to expose
information about guard regions. This allows userspace tools, such as
CRIU, to detect and handle guard regions.

Link: https://lkml.kernel.org/r/20250324065328.107678-1-avagin@google.com
Link: https://lkml.kernel.org/r/20250324065328.107678-2-avagin@google.com
Signed-off-by: Andrei Vagin <avagin@gmail.com>
Acked-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Andrei Vagin and committed by
Andrew Morton
a5164037 7eeafde0

+12 -7
+1
Documentation/admin-guide/mm/pagemap.rst
··· 250 250 - ``PAGE_IS_PFNZERO`` - Page has zero PFN 251 251 - ``PAGE_IS_HUGE`` - Page is PMD-mapped THP or Hugetlb backed 252 252 - ``PAGE_IS_SOFT_DIRTY`` - Page is soft-dirty 253 + - ``PAGE_IS_GUARD`` - Page is a part of a guard region 253 254 254 255 The ``struct pm_scan_arg`` is used as the argument of the IOCTL. 255 256
+10 -7
fs/proc/task_mmu.c
··· 2087 2087 #define PM_SCAN_CATEGORIES (PAGE_IS_WPALLOWED | PAGE_IS_WRITTEN | \ 2088 2088 PAGE_IS_FILE | PAGE_IS_PRESENT | \ 2089 2089 PAGE_IS_SWAPPED | PAGE_IS_PFNZERO | \ 2090 - PAGE_IS_HUGE | PAGE_IS_SOFT_DIRTY) 2090 + PAGE_IS_HUGE | PAGE_IS_SOFT_DIRTY | \ 2091 + PAGE_IS_GUARD) 2091 2092 #define PM_SCAN_FLAGS (PM_SCAN_WP_MATCHING | PM_SCAN_CHECK_WPASYNC) 2092 2093 2093 2094 struct pagemap_scan_private { ··· 2129 2128 if (!pte_swp_uffd_wp_any(pte)) 2130 2129 categories |= PAGE_IS_WRITTEN; 2131 2130 2132 - if (p->masks_of_interest & PAGE_IS_FILE) { 2133 - swp = pte_to_swp_entry(pte); 2134 - if (is_pfn_swap_entry(swp) && 2135 - !folio_test_anon(pfn_swap_entry_folio(swp))) 2136 - categories |= PAGE_IS_FILE; 2137 - } 2131 + swp = pte_to_swp_entry(pte); 2132 + if (is_guard_swp_entry(swp)) 2133 + categories |= PAGE_IS_GUARD; 2134 + else if ((p->masks_of_interest & PAGE_IS_FILE) && 2135 + is_pfn_swap_entry(swp) && 2136 + !folio_test_anon(pfn_swap_entry_folio(swp))) 2137 + categories |= PAGE_IS_FILE; 2138 + 2138 2139 if (pte_swp_soft_dirty(pte)) 2139 2140 categories |= PAGE_IS_SOFT_DIRTY; 2140 2141 }
+1
include/uapi/linux/fs.h
··· 361 361 #define PAGE_IS_PFNZERO (1 << 5) 362 362 #define PAGE_IS_HUGE (1 << 6) 363 363 #define PAGE_IS_SOFT_DIRTY (1 << 7) 364 + #define PAGE_IS_GUARD (1 << 8) 364 365 365 366 /* 366 367 * struct page_region - Page region with flags