FAILED: patch "[PATCH] fs/proc/task_mmu: fix PAGEMAP_SCAN written state for" failed to apply to 6.12-stable tree
Subsystems (5)
[email protected]
maintainerThe patch below does not apply to the 6.12-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x 07b4377bdbe74a3ec0c8da5849d014f70e003384
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026080504-lagged-gutless-4701@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 07b4377bdbe74a3ec0c8da5849d014f70e003384 Mon Sep 17 00:00:00 2001
From: "Kiryl Shutsemau (Meta)" <[email protected]>
Date: Tue, 7 Jul 2026 16:13:49 +0100
Subject: [PATCH] fs/proc/task_mmu: fix PAGEMAP_SCAN written state for
unpopulated ptes
PAGEMAP_SCAN reports an unpopulated pte differently depending on which path serves the request. The PAGE_IS_WRITTEN fast path in pagemap_scan_pmd_entry() reports a pte_none as written (and, under PM_SCAN_WP_MATCHING, arms a marker); pagemap_page_category() returns 0 for the same pte_none. A request that cannot take the fast path (an extra category bit, category_anyof_mask or category_inverted) therefore reports the pte as clean and skips arming it.
A range that was populated and then MADV_DONTNEED'd reads as written via one mask and clean via another, and in the latter case is not re-armed for the next round -- an incremental-dump consumer (e.g. CRIU) using a richer mask drops the zapped range and stops tracking writes to it.
Report pte_none as written in pagemap_page_category() too. A pte_none carries no uffd-wp marker, i.e. it is not write-protected -- the same condition under which the present and swap cases already report PAGE_IS_WRITTEN. The fast path applies no VMA test, so neither does this.
The hugetlb and fully-unpopulated-PMD (no page table) scans have no PAGE_IS_WRITTEN fast path, so they do not exhibit the per-entry divergence and are left unchanged.
Add a pagemap_ioctl selftest that populates a range, drops it with MADV_DONTNEED, and checks that the fast path and the generic (category_anyof_mask) path both report every page written.
fs/proc/task_mmu.c +12 -2
@@ -2432,8 +2432,18 @@ static unsigned long pagemap_page_category(struct pagemap_scan_private *p, {unsigned long categories; -if (pte_none (pte)) -return 0 ; +if (pte_none (pte)) { +/* +* An unpopulated pte carries no uffd-wp marker, i.e. it is not +* write-protected, the same condition under which the present +* and swap cases below report PAGE_IS_WRITTEN. Report it here +* too so this generic path agrees with the PAGE_IS_WRITTEN fast +* path in pagemap_scan_pmd_entry(), which reports pte_none as +* written and, under PM_SCAN_WP_MATCHING, arms a marker. The +* fast path applies no VMA test, so neither does this. +*/ +return PAGE_IS_WRITTEN ; + }if (pte_present (pte)) {struct page *page;
tools/testing/selftests/mm/pagemap_ioctl.c +55 -1
74 lines not on this page · raw message
PATCH 1/1 fs/proc/task_mmu: fix PAGEMAP_SCAN written state for unpopulated ptes
From: "Kiryl Shutsemau (Meta)" <[email protected]>
PAGEMAP_SCAN reports an unpopulated pte differently depending on which path serves the request. The PAGE_IS_WRITTEN fast path in pagemap_scan_pmd_entry() reports a pte_none as written (and, under PM_SCAN_WP_MATCHING, arms a marker); pagemap_page_category() returns 0 for the same pte_none. A request that cannot take the fast path (an extra category bit, category_anyof_mask or category_inverted) therefore reports the pte as clean and skips arming it.
A range that was populated and then MADV_DONTNEED'd reads as written via one mask and clean via another, and in the latter case is not re-armed for the next round -- an incremental-dump consumer (e.g. CRIU) using a richer mask drops the zapped range and stops tracking writes to it.
Report pte_none as written in pagemap_page_category() too. A pte_none carries no uffd-wp marker, i.e. it is not write-protected -- the same condition under which the present and swap cases already report PAGE_IS_WRITTEN. The fast path applies no VMA test, so neither does this.
The hugetlb and fully-unpopulated-PMD (no page table) scans have no PAGE_IS_WRITTEN fast path, so they do not exhibit the per-entry divergence and are left unchanged.
Add a pagemap_ioctl selftest that populates a range, drops it with MADV_DONTNEED, and checks that the fast path and the generic (category_anyof_mask) path both report every page written.
--- fs/proc/task_mmu.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
fs/proc/task_mmu.c +13 -0
@@ -2097,6 +2097,19 @@ static unsigned long pagemap_page_category(struct pagemap_scan_private *p, {unsigned long categories =0 ; +if (pte_none (pte)) { +/* +* An unpopulated pte carries no uffd-wp marker, i.e. it is not +* write-protected, the same condition under which the present +* and swap cases below report PAGE_IS_WRITTEN. Report it here +* too so this generic path agrees with the PAGE_IS_WRITTEN fast +* path in pagemap_scan_pmd_entry(), which reports pte_none as +* written and, under PM_SCAN_WP_MATCHING, arms a marker. The +* fast path applies no VMA test, so neither does this. +*/ +return PAGE_IS_WRITTEN ; + } +if (pte_present (pte)) {struct page *page;
Signature · 1 line
2.54.0
Re: [PATCH 6.12.y] fs/proc/task_mmu: fix PAGEMAP_SCAN written state for unpopulated ptes
Quoted 4 lines · Kiryl Shutsemau
Report
pte_noneas written inpagemap_page_category()too. Apte_nonecarries no uffd-wp marker, i.e. it is not write-protected -- the same condition under which the present and swap cases already reportPAGE_IS_WRITTEN.
Queued for 6.12, thanks.
Signature · 2 lines
Thanks, Sasha