Skip to content

Commit de9ad97

Browse files
committed
apply madv_guard API for CRIU
1 parent 0699da8 commit de9ad97

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

fs/proc/task_mmu.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,6 +1632,7 @@ struct pagemapread {
16321632
#define PM_SOFT_DIRTY BIT_ULL(55)
16331633
#define PM_MMAP_EXCLUSIVE BIT_ULL(56)
16341634
#define PM_UFFD_WP BIT_ULL(57)
1635+
#define PM_GUARD_REGION BIT_ULL(58)
16351636
#define PM_FILE BIT_ULL(61)
16361637
#define PM_SWAP BIT_ULL(62)
16371638
#define PM_PRESENT BIT_ULL(63)
@@ -1732,6 +1733,8 @@ static pagemap_entry_t pte_to_pagemap_entry(struct pagemapread *pm,
17321733
page = pfn_swap_entry_to_page(entry);
17331734
if (pte_marker_entry_uffd_wp(entry))
17341735
flags |= PM_UFFD_WP;
1736+
if (is_guard_swp_entry(entry))
1737+
flags |= PM_GUARD_REGION;
17351738
}
17361739

17371740
if (page) {
@@ -2063,7 +2066,8 @@ static int pagemap_release(struct inode *inode, struct file *file)
20632066
#define PM_SCAN_CATEGORIES (PAGE_IS_WPALLOWED | PAGE_IS_WRITTEN | \
20642067
PAGE_IS_FILE | PAGE_IS_PRESENT | \
20652068
PAGE_IS_SWAPPED | PAGE_IS_PFNZERO | \
2066-
PAGE_IS_HUGE | PAGE_IS_SOFT_DIRTY)
2069+
PAGE_IS_HUGE | PAGE_IS_SOFT_DIRTY | \
2070+
PAGE_IS_GUARD)
20672071
#define PM_SCAN_FLAGS (PM_SCAN_WP_MATCHING | PM_SCAN_CHECK_WPASYNC)
20682072

20692073
struct pagemap_scan_private {
@@ -2104,8 +2108,12 @@ static unsigned long pagemap_page_category(struct pagemap_scan_private *p,
21042108
if (!pte_swp_uffd_wp_any(pte))
21052109
categories |= PAGE_IS_WRITTEN;
21062110

2111+
swp = pte_to_swp_entry(pte);
2112+
if (is_guard_swp_entry(swp))
2113+
categories |= PAGE_IS_GUARD;
2114+
21072115
if (p->masks_of_interest & PAGE_IS_FILE) {
2108-
swp = pte_to_swp_entry(pte);
2116+
21092117
if (is_pfn_swap_entry(swp) &&
21102118
!folio_test_anon(pfn_swap_entry_folio(swp)))
21112119
categories |= PAGE_IS_FILE;

include/uapi/linux/fs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ typedef int __bitwise __kernel_rwf_t;
350350
#define PAGE_IS_PFNZERO (1 << 5)
351351
#define PAGE_IS_HUGE (1 << 6)
352352
#define PAGE_IS_SOFT_DIRTY (1 << 7)
353+
#define PAGE_IS_GUARD (1 << 8)
353354

354355
/*
355356
* struct page_region - Page region with flags

0 commit comments

Comments
 (0)