* [PATCH 0/2] fs/proc: extend the PAGEMAP_SCAN ioctl to report
@ 2025-03-20 6:39 Andrei Vagin
2025-03-20 6:39 ` [PATCH 1/2] fs/proc: extend the PAGEMAP_SCAN ioctl to report guard regions Andrei Vagin
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Andrei Vagin @ 2025-03-20 6:39 UTC (permalink / raw)
To: Lorenzo Stoakes, Andrew Morton
Cc: linux-kernel, linux-mm, linux-fsdevel, linux-doc,
David Hildenbrand, Shuah Khan, Jonathan Corbet, Andrei Vagin
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.
This series should be applied on top of "[PATCH 0/2] fs/proc/task_mmu:
add guard region bit to pagemap":
https://lore.kernel.org/all/2025031926-engraved-footer-3e9b@gregkh/T/
The series includes updates to the documentation and selftests to
reflect the new functionality.
Andrei Vagin (2):
fs/proc: extend the PAGEMAP_SCAN ioctl to report guard regions
selftests/mm: add PAGEMAP_SCAN guard region test
Documentation/admin-guide/mm/pagemap.rst | 1 +
fs/proc/task_mmu.c | 8 +++-
include/uapi/linux/fs.h | 1 +
tools/testing/selftests/mm/guard-regions.c | 53 ++++++++++++++++++++++
4 files changed, 61 insertions(+), 2 deletions(-)
--
2.49.0.rc1.451.g8f38331e32-goog
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2] fs/proc: extend the PAGEMAP_SCAN ioctl to report guard regions
2025-03-20 6:39 [PATCH 0/2] fs/proc: extend the PAGEMAP_SCAN ioctl to report Andrei Vagin
@ 2025-03-20 6:39 ` Andrei Vagin
2025-03-20 10:51 ` Lorenzo Stoakes
2025-03-21 10:49 ` David Hildenbrand
2025-03-20 6:39 ` [PATCH 2/2] selftests/mm: add PAGEMAP_SCAN guard region test Andrei Vagin
2025-03-20 10:57 ` [PATCH 0/2] fs/proc: extend the PAGEMAP_SCAN ioctl to report Lorenzo Stoakes
2 siblings, 2 replies; 9+ messages in thread
From: Andrei Vagin @ 2025-03-20 6:39 UTC (permalink / raw)
To: Lorenzo Stoakes, Andrew Morton
Cc: linux-kernel, linux-mm, linux-fsdevel, linux-doc,
David Hildenbrand, Shuah Khan, Jonathan Corbet, Andrei Vagin
From: Andrei Vagin <avagin@gmail.com>
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.
Signed-off-by: Andrei Vagin <avagin@gmail.com>
---
Documentation/admin-guide/mm/pagemap.rst | 1 +
fs/proc/task_mmu.c | 8 ++++++--
include/uapi/linux/fs.h | 1 +
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/Documentation/admin-guide/mm/pagemap.rst b/Documentation/admin-guide/mm/pagemap.rst
index a297e824f990..7997b67ffc97 100644
--- a/Documentation/admin-guide/mm/pagemap.rst
+++ b/Documentation/admin-guide/mm/pagemap.rst
@@ -234,6 +234,7 @@ Following flags about pages are currently supported:
- ``PAGE_IS_PFNZERO`` - Page has zero PFN
- ``PAGE_IS_HUGE`` - Page is PMD-mapped THP or Hugetlb backed
- ``PAGE_IS_SOFT_DIRTY`` - Page is soft-dirty
+- ``PAGE_IS_GUARD`` - Page is a guard region
The ``struct pm_scan_arg`` is used as the argument of the IOCTL.
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index c17615e21a5d..698d660bfee4 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -2067,7 +2067,8 @@ static int pagemap_release(struct inode *inode, struct file *file)
#define PM_SCAN_CATEGORIES (PAGE_IS_WPALLOWED | PAGE_IS_WRITTEN | \
PAGE_IS_FILE | PAGE_IS_PRESENT | \
PAGE_IS_SWAPPED | PAGE_IS_PFNZERO | \
- PAGE_IS_HUGE | PAGE_IS_SOFT_DIRTY)
+ PAGE_IS_HUGE | PAGE_IS_SOFT_DIRTY | \
+ PAGE_IS_GUARD)
#define PM_SCAN_FLAGS (PM_SCAN_WP_MATCHING | PM_SCAN_CHECK_WPASYNC)
struct pagemap_scan_private {
@@ -2108,8 +2109,11 @@ static unsigned long pagemap_page_category(struct pagemap_scan_private *p,
if (!pte_swp_uffd_wp_any(pte))
categories |= PAGE_IS_WRITTEN;
+ swp = pte_to_swp_entry(pte);
+ if (is_guard_swp_entry(swp))
+ categories |= PAGE_IS_GUARD;
+
if (p->masks_of_interest & PAGE_IS_FILE) {
- swp = pte_to_swp_entry(pte);
if (is_pfn_swap_entry(swp) &&
!folio_test_anon(pfn_swap_entry_folio(swp)))
categories |= PAGE_IS_FILE;
diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h
index 2bbe00cf1248..8aa66c5f69b7 100644
--- a/include/uapi/linux/fs.h
+++ b/include/uapi/linux/fs.h
@@ -363,6 +363,7 @@ typedef int __bitwise __kernel_rwf_t;
#define PAGE_IS_PFNZERO (1 << 5)
#define PAGE_IS_HUGE (1 << 6)
#define PAGE_IS_SOFT_DIRTY (1 << 7)
+#define PAGE_IS_GUARD (1 << 8)
/*
* struct page_region - Page region with flags
--
2.49.0.rc1.451.g8f38331e32-goog
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/2] selftests/mm: add PAGEMAP_SCAN guard region test
2025-03-20 6:39 [PATCH 0/2] fs/proc: extend the PAGEMAP_SCAN ioctl to report Andrei Vagin
2025-03-20 6:39 ` [PATCH 1/2] fs/proc: extend the PAGEMAP_SCAN ioctl to report guard regions Andrei Vagin
@ 2025-03-20 6:39 ` Andrei Vagin
2025-03-20 10:38 ` Lorenzo Stoakes
2025-03-20 10:57 ` [PATCH 0/2] fs/proc: extend the PAGEMAP_SCAN ioctl to report Lorenzo Stoakes
2 siblings, 1 reply; 9+ messages in thread
From: Andrei Vagin @ 2025-03-20 6:39 UTC (permalink / raw)
To: Lorenzo Stoakes, Andrew Morton
Cc: linux-kernel, linux-mm, linux-fsdevel, linux-doc,
David Hildenbrand, Shuah Khan, Jonathan Corbet, Andrei Vagin
From: Andrei Vagin <avagin@gmail.com>
Add a selftest to verify the PAGEMAP_SCAN ioctl correctly reports guard
regions using the newly introduced PAGE_IS_GUARD flag.
Signed-off-by: Andrei Vagin <avagin@gmail.com>
---
tools/testing/selftests/mm/guard-regions.c | 53 ++++++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/tools/testing/selftests/mm/guard-regions.c b/tools/testing/selftests/mm/guard-regions.c
index 0c7183e8b661..24e09092fda5 100644
--- a/tools/testing/selftests/mm/guard-regions.c
+++ b/tools/testing/selftests/mm/guard-regions.c
@@ -8,6 +8,7 @@
#include <fcntl.h>
#include <linux/limits.h>
#include <linux/userfaultfd.h>
+#include <linux/fs.h>
#include <setjmp.h>
#include <signal.h>
#include <stdbool.h>
@@ -2079,4 +2080,56 @@ TEST_F(guard_regions, pagemap)
ASSERT_EQ(munmap(ptr, 10 * page_size), 0);
}
+/*
+ * Assert that PAGEMAP_SCAN correctly reports guard region ranges.
+ */
+TEST_F(guard_regions, pagemap_scan)
+{
+ const unsigned long page_size = self->page_size;
+ struct page_region pm_regs[10];
+ struct pm_scan_arg pm_scan_args = {
+ .size = sizeof(struct pm_scan_arg),
+ .category_anyof_mask = PAGE_IS_GUARD,
+ .return_mask = PAGE_IS_GUARD,
+ .vec = (long)&pm_regs,
+ .vec_len = ARRAY_SIZE(pm_regs),
+ };
+ int proc_fd, i;
+ char *ptr;
+
+ proc_fd = open("/proc/self/pagemap", O_RDONLY);
+ ASSERT_NE(proc_fd, -1);
+
+ ptr = mmap_(self, variant, NULL, 10 * page_size,
+ PROT_READ | PROT_WRITE, 0, 0);
+ ASSERT_NE(ptr, MAP_FAILED);
+
+ pm_scan_args.start = (long)ptr;
+ pm_scan_args.end = (long)ptr + 10 * page_size;
+ ASSERT_EQ(ioctl(proc_fd, PAGEMAP_SCAN, &pm_scan_args), 0);
+ ASSERT_EQ(pm_scan_args.walk_end, (long)ptr + 10 * page_size);
+
+ /* Install a guard region in every other page. */
+ for (i = 0; i < 10; i += 2) {
+ char *ptr_p = &ptr[i * page_size];
+
+ ASSERT_EQ(syscall(__NR_madvise, ptr_p, page_size, MADV_GUARD_INSTALL), 0);
+ }
+
+ ASSERT_EQ(ioctl(proc_fd, PAGEMAP_SCAN, &pm_scan_args), 5);
+ ASSERT_EQ(pm_scan_args.walk_end, (long)ptr + 10 * page_size);
+
+ /* Re-read from pagemap, and assert guard regions are detected. */
+ for (i = 0; i < 5; i++) {
+ long ptr_p = (long)&ptr[2 * i * page_size];
+
+ ASSERT_EQ(pm_regs[i].start, ptr_p);
+ ASSERT_EQ(pm_regs[i].end, ptr_p + page_size);
+ ASSERT_EQ(pm_regs[i].categories, PAGE_IS_GUARD);
+ }
+
+ ASSERT_EQ(close(proc_fd), 0);
+ ASSERT_EQ(munmap(ptr, 10 * page_size), 0);
+}
+
TEST_HARNESS_MAIN
--
2.49.0.rc1.451.g8f38331e32-goog
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] selftests/mm: add PAGEMAP_SCAN guard region test
2025-03-20 6:39 ` [PATCH 2/2] selftests/mm: add PAGEMAP_SCAN guard region test Andrei Vagin
@ 2025-03-20 10:38 ` Lorenzo Stoakes
0 siblings, 0 replies; 9+ messages in thread
From: Lorenzo Stoakes @ 2025-03-20 10:38 UTC (permalink / raw)
To: Andrei Vagin
Cc: Andrew Morton, linux-kernel, linux-mm, linux-fsdevel, linux-doc,
David Hildenbrand, Shuah Khan, Jonathan Corbet, Andrei Vagin
On Thu, Mar 20, 2025 at 06:39:03AM +0000, Andrei Vagin wrote:
> From: Andrei Vagin <avagin@gmail.com>
>
> Add a selftest to verify the PAGEMAP_SCAN ioctl correctly reports guard
> regions using the newly introduced PAGE_IS_GUARD flag.
>
> Signed-off-by: Andrei Vagin <avagin@gmail.com>
> ---
> tools/testing/selftests/mm/guard-regions.c | 53 ++++++++++++++++++++++
> 1 file changed, 53 insertions(+)
>
> diff --git a/tools/testing/selftests/mm/guard-regions.c b/tools/testing/selftests/mm/guard-regions.c
> index 0c7183e8b661..24e09092fda5 100644
> --- a/tools/testing/selftests/mm/guard-regions.c
> +++ b/tools/testing/selftests/mm/guard-regions.c
> @@ -8,6 +8,7 @@
> #include <fcntl.h>
> #include <linux/limits.h>
> #include <linux/userfaultfd.h>
> +#include <linux/fs.h>
This is insufficient, you also need to update tools/include/uapi/linux/fs.h
- we don't want to have to rely on make headers for these tests.
Basically just:
cp include/uapi/linux/fs.h tools/include/uapi/linux/fs.h
And commit this (you can see format of commit messages like this in git log
for that file).
Thanks!
> #include <setjmp.h>
> #include <signal.h>
> #include <stdbool.h>
> @@ -2079,4 +2080,56 @@ TEST_F(guard_regions, pagemap)
> ASSERT_EQ(munmap(ptr, 10 * page_size), 0);
> }
>
> +/*
> + * Assert that PAGEMAP_SCAN correctly reports guard region ranges.
> + */
> +TEST_F(guard_regions, pagemap_scan)
> +{
> + const unsigned long page_size = self->page_size;
> + struct page_region pm_regs[10];
> + struct pm_scan_arg pm_scan_args = {
> + .size = sizeof(struct pm_scan_arg),
> + .category_anyof_mask = PAGE_IS_GUARD,
> + .return_mask = PAGE_IS_GUARD,
> + .vec = (long)&pm_regs,
> + .vec_len = ARRAY_SIZE(pm_regs),
> + };
Yeah this interface is quite nice actually... :)
> + int proc_fd, i;
> + char *ptr;
> +
> + proc_fd = open("/proc/self/pagemap", O_RDONLY);
> + ASSERT_NE(proc_fd, -1);
> +
> + ptr = mmap_(self, variant, NULL, 10 * page_size,
> + PROT_READ | PROT_WRITE, 0, 0);
> + ASSERT_NE(ptr, MAP_FAILED);
> +
> + pm_scan_args.start = (long)ptr;
> + pm_scan_args.end = (long)ptr + 10 * page_size;
> + ASSERT_EQ(ioctl(proc_fd, PAGEMAP_SCAN, &pm_scan_args), 0);
> + ASSERT_EQ(pm_scan_args.walk_end, (long)ptr + 10 * page_size);
> +
> + /* Install a guard region in every other page. */
> + for (i = 0; i < 10; i += 2) {
> + char *ptr_p = &ptr[i * page_size];
> +
> + ASSERT_EQ(syscall(__NR_madvise, ptr_p, page_size, MADV_GUARD_INSTALL), 0);
> + }
> +
> + ASSERT_EQ(ioctl(proc_fd, PAGEMAP_SCAN, &pm_scan_args), 5);
Nit but might be worth saying that you're asserting 5 because every other
over 10.
As trivial as;
/* Assert ioctl() returns the count of located pages */
Which I presume it does right?
> + ASSERT_EQ(pm_scan_args.walk_end, (long)ptr + 10 * page_size);
> +
> + /* Re-read from pagemap, and assert guard regions are detected. */
> + for (i = 0; i < 5; i++) {
> + long ptr_p = (long)&ptr[2 * i * page_size];
> +
> + ASSERT_EQ(pm_regs[i].start, ptr_p);
> + ASSERT_EQ(pm_regs[i].end, ptr_p + page_size);
> + ASSERT_EQ(pm_regs[i].categories, PAGE_IS_GUARD);
> + }
> +
> + ASSERT_EQ(close(proc_fd), 0);
> + ASSERT_EQ(munmap(ptr, 10 * page_size), 0);
> +}
Generally test looks ok though, thanks! Passing in my setup.
> +
> TEST_HARNESS_MAIN
> --
> 2.49.0.rc1.451.g8f38331e32-goog
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] fs/proc: extend the PAGEMAP_SCAN ioctl to report guard regions
2025-03-20 6:39 ` [PATCH 1/2] fs/proc: extend the PAGEMAP_SCAN ioctl to report guard regions Andrei Vagin
@ 2025-03-20 10:51 ` Lorenzo Stoakes
2025-03-21 10:49 ` David Hildenbrand
1 sibling, 0 replies; 9+ messages in thread
From: Lorenzo Stoakes @ 2025-03-20 10:51 UTC (permalink / raw)
To: Andrei Vagin
Cc: Andrew Morton, linux-kernel, linux-mm, linux-fsdevel, linux-doc,
David Hildenbrand, Shuah Khan, Jonathan Corbet, Andrei Vagin
On Thu, Mar 20, 2025 at 06:39:02AM +0000, Andrei Vagin wrote:
> From: Andrei Vagin <avagin@gmail.com>
>
> 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.
>
> Signed-off-by: Andrei Vagin <avagin@gmail.com>
This looks fine thanks!
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> ---
> Documentation/admin-guide/mm/pagemap.rst | 1 +
> fs/proc/task_mmu.c | 8 ++++++--
> include/uapi/linux/fs.h | 1 +
> 3 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/admin-guide/mm/pagemap.rst b/Documentation/admin-guide/mm/pagemap.rst
> index a297e824f990..7997b67ffc97 100644
> --- a/Documentation/admin-guide/mm/pagemap.rst
> +++ b/Documentation/admin-guide/mm/pagemap.rst
> @@ -234,6 +234,7 @@ Following flags about pages are currently supported:
> - ``PAGE_IS_PFNZERO`` - Page has zero PFN
> - ``PAGE_IS_HUGE`` - Page is PMD-mapped THP or Hugetlb backed
> - ``PAGE_IS_SOFT_DIRTY`` - Page is soft-dirty
> +- ``PAGE_IS_GUARD`` - Page is a guard region
NIT: 'part of' a guard region.
>
> The ``struct pm_scan_arg`` is used as the argument of the IOCTL.
>
> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
> index c17615e21a5d..698d660bfee4 100644
> --- a/fs/proc/task_mmu.c
> +++ b/fs/proc/task_mmu.c
> @@ -2067,7 +2067,8 @@ static int pagemap_release(struct inode *inode, struct file *file)
> #define PM_SCAN_CATEGORIES (PAGE_IS_WPALLOWED | PAGE_IS_WRITTEN | \
> PAGE_IS_FILE | PAGE_IS_PRESENT | \
> PAGE_IS_SWAPPED | PAGE_IS_PFNZERO | \
> - PAGE_IS_HUGE | PAGE_IS_SOFT_DIRTY)
> + PAGE_IS_HUGE | PAGE_IS_SOFT_DIRTY | \
> + PAGE_IS_GUARD)
> #define PM_SCAN_FLAGS (PM_SCAN_WP_MATCHING | PM_SCAN_CHECK_WPASYNC)
>
> struct pagemap_scan_private {
> @@ -2108,8 +2109,11 @@ static unsigned long pagemap_page_category(struct pagemap_scan_private *p,
> if (!pte_swp_uffd_wp_any(pte))
> categories |= PAGE_IS_WRITTEN;
>
You don't show it, but kinda hate how we mark this as swapped even though,
you know, it's not... but we already do that for uffd pte markers, and
equally the guard marker for /proc/$pid/pagemap, so yeah it's consistent,
but still weird.
But fine, I guess that's something that already happened for uffd PTE
markers, and somebody searching for swapped is going to be shown guard
region pages too (and _right now_ would).
(This is a grumble/mumble rather than review comment, really :P)
> + swp = pte_to_swp_entry(pte);
Total nit, but prefer either to add a newline after this or delete newline
after the block below just to indicate swp is used for all.
> + if (is_guard_swp_entry(swp))
> + categories |= PAGE_IS_GUARD;
> +
To be honest, nit-wise, I'd opt for just dropping this line... :) yeah I
know, the most petty thing ever! ;)
> if (p->masks_of_interest & PAGE_IS_FILE) {
> - swp = pte_to_swp_entry(pte);
> if (is_pfn_swap_entry(swp) &&
> !folio_test_anon(pfn_swap_entry_folio(swp)))
> categories |= PAGE_IS_FILE;
> diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h
> index 2bbe00cf1248..8aa66c5f69b7 100644
> --- a/include/uapi/linux/fs.h
> +++ b/include/uapi/linux/fs.h
> @@ -363,6 +363,7 @@ typedef int __bitwise __kernel_rwf_t;
> #define PAGE_IS_PFNZERO (1 << 5)
> #define PAGE_IS_HUGE (1 << 6)
> #define PAGE_IS_SOFT_DIRTY (1 << 7)
> +#define PAGE_IS_GUARD (1 << 8)
>
> /*
> * struct page_region - Page region with flags
> --
> 2.49.0.rc1.451.g8f38331e32-goog
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/2] fs/proc: extend the PAGEMAP_SCAN ioctl to report
2025-03-20 6:39 [PATCH 0/2] fs/proc: extend the PAGEMAP_SCAN ioctl to report Andrei Vagin
2025-03-20 6:39 ` [PATCH 1/2] fs/proc: extend the PAGEMAP_SCAN ioctl to report guard regions Andrei Vagin
2025-03-20 6:39 ` [PATCH 2/2] selftests/mm: add PAGEMAP_SCAN guard region test Andrei Vagin
@ 2025-03-20 10:57 ` Lorenzo Stoakes
2025-03-20 15:00 ` Andrei Vagin
2 siblings, 1 reply; 9+ messages in thread
From: Lorenzo Stoakes @ 2025-03-20 10:57 UTC (permalink / raw)
To: Andrei Vagin
Cc: Andrew Morton, linux-kernel, linux-mm, linux-fsdevel, linux-doc,
David Hildenbrand, Shuah Khan, Jonathan Corbet
Well I guess it couldn't wait ;) we're (very!) late in the cycle and
immediately pre-LSF (will you be there btw?) so this is 6.16 for sure.
Kinda wish you'd mentioned you wanted to do it as I'd rearranged my
schedule to tackle this as a priority post-LSF, but you've done a good job
so we're all good! Just a little heads up would have been nice ;)
Some nits and you need to fix the test header thing but otherwise good.
On Thu, Mar 20, 2025 at 06:39:01AM +0000, Andrei Vagin wrote:
> 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.
Might be worth underlining why it is so crucial for CRIU, and what
advantages PAGEMAP_SCAN confers.
>
> This series should be applied on top of "[PATCH 0/2] fs/proc/task_mmu:
> add guard region bit to pagemap":
> https://lore.kernel.org/all/2025031926-engraved-footer-3e9b@gregkh/T/
No need for this, this applies fine against mm-unstable, though we're
looking at 6.16 for this now obviously.
>
> The series includes updates to the documentation and selftests to
> reflect the new functionality.
I love to see it! :>)
Please also, once this moves along, send an update to the manpage please.
>
> Andrei Vagin (2):
> fs/proc: extend the PAGEMAP_SCAN ioctl to report guard regions
> selftests/mm: add PAGEMAP_SCAN guard region test
>
> Documentation/admin-guide/mm/pagemap.rst | 1 +
> fs/proc/task_mmu.c | 8 +++-
> include/uapi/linux/fs.h | 1 +
> tools/testing/selftests/mm/guard-regions.c | 53 ++++++++++++++++++++++
> 4 files changed, 61 insertions(+), 2 deletions(-)
>
> --
> 2.49.0.rc1.451.g8f38331e32-goog
>
Cheers, Lorenzo
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/2] fs/proc: extend the PAGEMAP_SCAN ioctl to report
2025-03-20 10:57 ` [PATCH 0/2] fs/proc: extend the PAGEMAP_SCAN ioctl to report Lorenzo Stoakes
@ 2025-03-20 15:00 ` Andrei Vagin
2025-03-21 9:49 ` Lorenzo Stoakes
0 siblings, 1 reply; 9+ messages in thread
From: Andrei Vagin @ 2025-03-20 15:00 UTC (permalink / raw)
To: Lorenzo Stoakes
Cc: Andrei Vagin, Andrew Morton, linux-kernel, linux-mm,
linux-fsdevel, linux-doc, David Hildenbrand, Shuah Khan,
Jonathan Corbet, criu, Alexander Mikhalitsyn, Pavel Tikhomirov
On Thu, Mar 20, 2025 at 4:04 AM Lorenzo Stoakes
<lorenzo.stoakes@oracle.com> wrote:
>
> Well I guess it couldn't wait ;) we're (very!) late in the cycle and
> immediately pre-LSF (will you be there btw?) so this is 6.16 for sure.
>
> Kinda wish you'd mentioned you wanted to do it as I'd rearranged my
> schedule to tackle this as a priority post-LSF, but you've done a good job
> so we're all good! Just a little heads up would have been nice ;)
>
> Some nits and you need to fix the test header thing but otherwise good.
I wasn't rushing these changes. Just trying to help and save you some
time:). We'd like to backport this to older releases, but that's a separate
task. I'll submit backport requests to the stable branches and hope
(fingers crossed) the maintainers approve them. Sorry I didn't let you know
I could help with this.
Thanks for the review.
P.S. I don't think I made the CRIU urgency clear enough earlier. We're not
in panic mode, and we do have time to handle this. The lightweight guard
regions are in glibc, but aren't in any distro releases yet. We found the
problem when CRIU tests started failing on Fedora Rawhide. We probably have
a few months before the new glibc hits official distros and becomes a real
issue for CRIU users.
Thanks,
Andrei
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/2] fs/proc: extend the PAGEMAP_SCAN ioctl to report
2025-03-20 15:00 ` Andrei Vagin
@ 2025-03-21 9:49 ` Lorenzo Stoakes
0 siblings, 0 replies; 9+ messages in thread
From: Lorenzo Stoakes @ 2025-03-21 9:49 UTC (permalink / raw)
To: Andrei Vagin
Cc: Andrei Vagin, Andrew Morton, linux-kernel, linux-mm,
linux-fsdevel, linux-doc, David Hildenbrand, Shuah Khan,
Jonathan Corbet, criu, Alexander Mikhalitsyn, Pavel Tikhomirov
On Thu, Mar 20, 2025 at 08:00:36AM -0700, Andrei Vagin wrote:
> On Thu, Mar 20, 2025 at 4:04 AM Lorenzo Stoakes
> <lorenzo.stoakes@oracle.com> wrote:
> >
> > Well I guess it couldn't wait ;) we're (very!) late in the cycle and
> > immediately pre-LSF (will you be there btw?) so this is 6.16 for sure.
> >
> > Kinda wish you'd mentioned you wanted to do it as I'd rearranged my
> > schedule to tackle this as a priority post-LSF, but you've done a good job
> > so we're all good! Just a little heads up would have been nice ;)
> >
> > Some nits and you need to fix the test header thing but otherwise good.
>
> I wasn't rushing these changes. Just trying to help and save you some
> time:). We'd like to backport this to older releases, but that's a separate
> task. I'll submit backport requests to the stable branches and hope
> (fingers crossed) the maintainers approve them. Sorry I didn't let you know
> I could help with this.
Please don't submit any backport requests yet, let me handle that for
both. I mean I'm a maintainer of memory mapping bits, at least, so I
approve from my side :)
Andrew's input is necessary for rest, but let me handle that just so we
don't step on each other's toes here too much!
>
> Thanks for the review.
>
> P.S. I don't think I made the CRIU urgency clear enough earlier. We're not
> in panic mode, and we do have time to handle this. The lightweight guard
> regions are in glibc, but aren't in any distro releases yet. We found the
> problem when CRIU tests started failing on Fedora Rawhide. We probably have
> a few months before the new glibc hits official distros and becomes a real
> issue for CRIU users.
Good! I am eager to avoid any issues here. You'll find us in mm to be
responsive :)
>
> Thanks,
> Andrei
Cheers, Lorenzo
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] fs/proc: extend the PAGEMAP_SCAN ioctl to report guard regions
2025-03-20 6:39 ` [PATCH 1/2] fs/proc: extend the PAGEMAP_SCAN ioctl to report guard regions Andrei Vagin
2025-03-20 10:51 ` Lorenzo Stoakes
@ 2025-03-21 10:49 ` David Hildenbrand
1 sibling, 0 replies; 9+ messages in thread
From: David Hildenbrand @ 2025-03-21 10:49 UTC (permalink / raw)
To: Andrei Vagin, Lorenzo Stoakes, Andrew Morton
Cc: linux-kernel, linux-mm, linux-fsdevel, linux-doc, Shuah Khan,
Jonathan Corbet, Andrei Vagin
On 20.03.25 07:39, Andrei Vagin wrote:
> From: Andrei Vagin <avagin@gmail.com>
>
> 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.
>
> Signed-off-by: Andrei Vagin <avagin@gmail.com>
> ---
> Documentation/admin-guide/mm/pagemap.rst | 1 +
> fs/proc/task_mmu.c | 8 ++++++--
> include/uapi/linux/fs.h | 1 +
> 3 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/admin-guide/mm/pagemap.rst b/Documentation/admin-guide/mm/pagemap.rst
> index a297e824f990..7997b67ffc97 100644
> --- a/Documentation/admin-guide/mm/pagemap.rst
> +++ b/Documentation/admin-guide/mm/pagemap.rst
> @@ -234,6 +234,7 @@ Following flags about pages are currently supported:
> - ``PAGE_IS_PFNZERO`` - Page has zero PFN
> - ``PAGE_IS_HUGE`` - Page is PMD-mapped THP or Hugetlb backed
> - ``PAGE_IS_SOFT_DIRTY`` - Page is soft-dirty
> +- ``PAGE_IS_GUARD`` - Page is a guard region
>
> The ``struct pm_scan_arg`` is used as the argument of the IOCTL.
>
> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
> index c17615e21a5d..698d660bfee4 100644
> --- a/fs/proc/task_mmu.c
> +++ b/fs/proc/task_mmu.c
> @@ -2067,7 +2067,8 @@ static int pagemap_release(struct inode *inode, struct file *file)
> #define PM_SCAN_CATEGORIES (PAGE_IS_WPALLOWED | PAGE_IS_WRITTEN | \
> PAGE_IS_FILE | PAGE_IS_PRESENT | \
> PAGE_IS_SWAPPED | PAGE_IS_PFNZERO | \
> - PAGE_IS_HUGE | PAGE_IS_SOFT_DIRTY)
> + PAGE_IS_HUGE | PAGE_IS_SOFT_DIRTY | \
> + PAGE_IS_GUARD)
> #define PM_SCAN_FLAGS (PM_SCAN_WP_MATCHING | PM_SCAN_CHECK_WPASYNC)
>
> struct pagemap_scan_private {
> @@ -2108,8 +2109,11 @@ static unsigned long pagemap_page_category(struct pagemap_scan_private *p,
> if (!pte_swp_uffd_wp_any(pte))
> categories |= PAGE_IS_WRITTEN;
>
> + swp = pte_to_swp_entry(pte);
> + if (is_guard_swp_entry(swp))
> + categories |= PAGE_IS_GUARD;
> +
> if (p->masks_of_interest & PAGE_IS_FILE) {
could be an else if?
if (is_guard_swp_entry(swp)) {
categories |= PAGE_IS_GUARD;
} else if (p->masks_of_interest & PAGE_IS_FILE) {
...
Acked-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-03-21 10:49 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-20 6:39 [PATCH 0/2] fs/proc: extend the PAGEMAP_SCAN ioctl to report Andrei Vagin
2025-03-20 6:39 ` [PATCH 1/2] fs/proc: extend the PAGEMAP_SCAN ioctl to report guard regions Andrei Vagin
2025-03-20 10:51 ` Lorenzo Stoakes
2025-03-21 10:49 ` David Hildenbrand
2025-03-20 6:39 ` [PATCH 2/2] selftests/mm: add PAGEMAP_SCAN guard region test Andrei Vagin
2025-03-20 10:38 ` Lorenzo Stoakes
2025-03-20 10:57 ` [PATCH 0/2] fs/proc: extend the PAGEMAP_SCAN ioctl to report Lorenzo Stoakes
2025-03-20 15:00 ` Andrei Vagin
2025-03-21 9:49 ` Lorenzo Stoakes
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).