From: David Hildenbrand <david@redhat.com>
To: Andrei Vagin <avagin@google.com>,
Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org,
Shuah Khan <shuah@kernel.org>, Jonathan Corbet <corbet@lwn.net>,
Andrei Vagin <avagin@gmail.com>
Subject: Re: [PATCH 1/2] fs/proc: extend the PAGEMAP_SCAN ioctl to report guard regions
Date: Fri, 21 Mar 2025 11:49:31 +0100 [thread overview]
Message-ID: <43657a07-617b-43fe-b0b0-689f2392fc63@redhat.com> (raw)
In-Reply-To: <20250320063903.2685882-2-avagin@google.com>
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
next prev parent reply other threads:[~2025-03-21 10:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=43657a07-617b-43fe-b0b0-689f2392fc63@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=avagin@gmail.com \
--cc=avagin@google.com \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).