* FAILED: patch "[PATCH] mm/truncate: unmap large folio on split failure" failed to apply to 6.17-stable tree
@ 2025-11-20 16:13 gregkh
2025-11-20 16:52 ` [PATCH 6.17.y] mm/truncate: unmap large folio on split failure Kiryl Shutsemau
0 siblings, 1 reply; 6+ messages in thread
From: gregkh @ 2025-11-20 16:13 UTC (permalink / raw)
To: kas, akpm, baolin.wang, brauner, david, david, djwong, hannes,
hughd, liam.howlett, lorenzo.stoakes, mhocko, riel, rppt,
shakeel.butt, stable, surenb, vbabka, viro, willy
Cc: stable
The patch below does not apply to the 6.17-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 <stable@vger.kernel.org>.
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.17.y
git checkout FETCH_HEAD
git cherry-pick -x fa04f5b60fda62c98a53a60de3a1e763f11feb41
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2025112037-resurface-backlight-da75@gregkh' --subject-prefix 'PATCH 6.17.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From fa04f5b60fda62c98a53a60de3a1e763f11feb41 Mon Sep 17 00:00:00 2001
From: Kiryl Shutsemau <kas@kernel.org>
Date: Mon, 27 Oct 2025 11:56:36 +0000
Subject: [PATCH] mm/truncate: unmap large folio on split failure
Accesses within VMA, but beyond i_size rounded up to PAGE_SIZE are
supposed to generate SIGBUS.
This behavior might not be respected on truncation.
During truncation, the kernel splits a large folio in order to reclaim
memory. As a side effect, it unmaps the folio and destroys PMD mappings
of the folio. The folio will be refaulted as PTEs and SIGBUS semantics
are preserved.
However, if the split fails, PMD mappings are preserved and the user will
not receive SIGBUS on any accesses within the PMD.
Unmap the folio on split failure. It will lead to refault as PTEs and
preserve SIGBUS semantics.
Make an exception for shmem/tmpfs that for long time intentionally mapped
with PMDs across i_size.
Link: https://lkml.kernel.org/r/20251027115636.82382-3-kirill@shutemov.name
Fixes: b9a8a4195c7d ("truncate,shmem: Handle truncates that split large folios")
Signed-off-by: Kiryl Shutsemau <kas@kernel.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: "Darrick J. Wong" <djwong@kernel.org>
Cc: Dave Chinner <david@fromorbit.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Rik van Riel <riel@surriel.com>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
diff --git a/mm/truncate.c b/mm/truncate.c
index 9210cf808f5c..3c5a50ae3274 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -177,6 +177,32 @@ int truncate_inode_folio(struct address_space *mapping, struct folio *folio)
return 0;
}
+static int try_folio_split_or_unmap(struct folio *folio, struct page *split_at,
+ unsigned long min_order)
+{
+ enum ttu_flags ttu_flags =
+ TTU_SYNC |
+ TTU_SPLIT_HUGE_PMD |
+ TTU_IGNORE_MLOCK;
+ int ret;
+
+ ret = try_folio_split_to_order(folio, split_at, min_order);
+
+ /*
+ * If the split fails, unmap the folio, so it will be refaulted
+ * with PTEs to respect SIGBUS semantics.
+ *
+ * Make an exception for shmem/tmpfs that for long time
+ * intentionally mapped with PMDs across i_size.
+ */
+ if (ret && !shmem_mapping(folio->mapping)) {
+ try_to_unmap(folio, ttu_flags);
+ WARN_ON(folio_mapped(folio));
+ }
+
+ return ret;
+}
+
/*
* Handle partial folios. The folio may be entirely within the
* range if a split has raced with us. If not, we zero the part of the
@@ -226,7 +252,7 @@ bool truncate_inode_partial_folio(struct folio *folio, loff_t start, loff_t end)
min_order = mapping_min_folio_order(folio->mapping);
split_at = folio_page(folio, PAGE_ALIGN_DOWN(offset) / PAGE_SIZE);
- if (!try_folio_split_to_order(folio, split_at, min_order)) {
+ if (!try_folio_split_or_unmap(folio, split_at, min_order)) {
/*
* try to split at offset + length to make sure folios within
* the range can be dropped, especially to avoid memory waste
@@ -250,13 +276,10 @@ bool truncate_inode_partial_folio(struct folio *folio, loff_t start, loff_t end)
if (!folio_trylock(folio2))
goto out;
- /*
- * make sure folio2 is large and does not change its mapping.
- * Its split result does not matter here.
- */
+ /* make sure folio2 is large and does not change its mapping */
if (folio_test_large(folio2) &&
folio2->mapping == folio->mapping)
- try_folio_split_to_order(folio2, split_at2, min_order);
+ try_folio_split_or_unmap(folio2, split_at2, min_order);
folio_unlock(folio2);
out:
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 6.17.y] mm/truncate: unmap large folio on split failure
2025-11-20 16:13 FAILED: patch "[PATCH] mm/truncate: unmap large folio on split failure" failed to apply to 6.17-stable tree gregkh
@ 2025-11-20 16:52 ` Kiryl Shutsemau
2025-11-21 9:46 ` Greg KH
0 siblings, 1 reply; 6+ messages in thread
From: Kiryl Shutsemau @ 2025-11-20 16:52 UTC (permalink / raw)
To: stable
Cc: Kiryl Shutsemau, Al Viro, Baolin Wang, Christian Brauner,
Darrick J. Wong, Dave Chinner, David Hildenbrand, Hugh Dickins,
Johannes Weiner, Liam Howlett, Lorenzo Stoakes,
Matthew Wilcox (Oracle), Michal Hocko, Mike Rapoport,
Rik van Riel, Shakeel Butt, Suren Baghdasaryan, Vlastimil Babka,
Andrew Morton
Accesses within VMA, but beyond i_size rounded up to PAGE_SIZE are
supposed to generate SIGBUS.
This behavior might not be respected on truncation.
During truncation, the kernel splits a large folio in order to reclaim
memory. As a side effect, it unmaps the folio and destroys PMD mappings
of the folio. The folio will be refaulted as PTEs and SIGBUS semantics
are preserved.
However, if the split fails, PMD mappings are preserved and the user will
not receive SIGBUS on any accesses within the PMD.
Unmap the folio on split failure. It will lead to refault as PTEs and
preserve SIGBUS semantics.
Make an exception for shmem/tmpfs that for long time intentionally mapped
with PMDs across i_size.
Link: https://lkml.kernel.org/r/20251027115636.82382-3-kirill@shutemov.name
Fixes: b9a8a4195c7d ("truncate,shmem: Handle truncates that split large folios")
Signed-off-by: Kiryl Shutsemau <kas@kernel.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: "Darrick J. Wong" <djwong@kernel.org>
Cc: Dave Chinner <david@fromorbit.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Rik van Riel <riel@surriel.com>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit fa04f5b60fda62c98a53a60de3a1e763f11feb41)
Signed-off-by: Kiryl Shutsemau <kas@kernel.org>
---
mm/truncate.c | 34 ++++++++++++++++++++++++++++------
1 file changed, 28 insertions(+), 6 deletions(-)
diff --git a/mm/truncate.c b/mm/truncate.c
index 91eb92a5ce4f..95fb291526fc 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -177,6 +177,31 @@ int truncate_inode_folio(struct address_space *mapping, struct folio *folio)
return 0;
}
+static int try_folio_split_or_unmap(struct folio *folio, struct page *split_at)
+{
+ enum ttu_flags ttu_flags =
+ TTU_SYNC |
+ TTU_SPLIT_HUGE_PMD |
+ TTU_IGNORE_MLOCK;
+ int ret;
+
+ ret = try_folio_split(folio, split_at, NULL);
+
+ /*
+ * If the split fails, unmap the folio, so it will be refaulted
+ * with PTEs to respect SIGBUS semantics.
+ *
+ * Make an exception for shmem/tmpfs that for long time
+ * intentionally mapped with PMDs across i_size.
+ */
+ if (ret && !shmem_mapping(folio->mapping)) {
+ try_to_unmap(folio, ttu_flags);
+ WARN_ON(folio_mapped(folio));
+ }
+
+ return ret;
+}
+
/*
* Handle partial folios. The folio may be entirely within the
* range if a split has raced with us. If not, we zero the part of the
@@ -224,7 +249,7 @@ bool truncate_inode_partial_folio(struct folio *folio, loff_t start, loff_t end)
return true;
split_at = folio_page(folio, PAGE_ALIGN_DOWN(offset) / PAGE_SIZE);
- if (!try_folio_split(folio, split_at, NULL)) {
+ if (!try_folio_split_or_unmap(folio, split_at)) {
/*
* try to split at offset + length to make sure folios within
* the range can be dropped, especially to avoid memory waste
@@ -248,13 +273,10 @@ bool truncate_inode_partial_folio(struct folio *folio, loff_t start, loff_t end)
if (!folio_trylock(folio2))
goto out;
- /*
- * make sure folio2 is large and does not change its mapping.
- * Its split result does not matter here.
- */
+ /* make sure folio2 is large and does not change its mapping */
if (folio_test_large(folio2) &&
folio2->mapping == folio->mapping)
- try_folio_split(folio2, split_at2, NULL);
+ try_folio_split_or_unmap(folio2, split_at2);
folio_unlock(folio2);
out:
--
2.51.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH 6.17.y] mm/truncate: unmap large folio on split failure
2025-11-20 16:52 ` [PATCH 6.17.y] mm/truncate: unmap large folio on split failure Kiryl Shutsemau
@ 2025-11-21 9:46 ` Greg KH
2025-11-21 13:20 ` Kiryl Shutsemau
0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2025-11-21 9:46 UTC (permalink / raw)
To: Kiryl Shutsemau
Cc: stable, Al Viro, Baolin Wang, Christian Brauner, Darrick J. Wong,
Dave Chinner, David Hildenbrand, Hugh Dickins, Johannes Weiner,
Liam Howlett, Lorenzo Stoakes, Matthew Wilcox (Oracle),
Michal Hocko, Mike Rapoport, Rik van Riel, Shakeel Butt,
Suren Baghdasaryan, Vlastimil Babka, Andrew Morton
On Thu, Nov 20, 2025 at 04:52:21PM +0000, Kiryl Shutsemau wrote:
> Accesses within VMA, but beyond i_size rounded up to PAGE_SIZE are
> supposed to generate SIGBUS.
>
> This behavior might not be respected on truncation.
>
> During truncation, the kernel splits a large folio in order to reclaim
> memory. As a side effect, it unmaps the folio and destroys PMD mappings
> of the folio. The folio will be refaulted as PTEs and SIGBUS semantics
> are preserved.
>
> However, if the split fails, PMD mappings are preserved and the user will
> not receive SIGBUS on any accesses within the PMD.
>
> Unmap the folio on split failure. It will lead to refault as PTEs and
> preserve SIGBUS semantics.
>
> Make an exception for shmem/tmpfs that for long time intentionally mapped
> with PMDs across i_size.
>
> Link: https://lkml.kernel.org/r/20251027115636.82382-3-kirill@shutemov.name
> Fixes: b9a8a4195c7d ("truncate,shmem: Handle truncates that split large folios")
> Signed-off-by: Kiryl Shutsemau <kas@kernel.org>
> Cc: Al Viro <viro@zeniv.linux.org.uk>
> Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
> Cc: Christian Brauner <brauner@kernel.org>
> Cc: "Darrick J. Wong" <djwong@kernel.org>
> Cc: Dave Chinner <david@fromorbit.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Hugh Dickins <hughd@google.com>
> Cc: Johannes Weiner <hannes@cmpxchg.org>
> Cc: Liam Howlett <liam.howlett@oracle.com>
> Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
> Cc: Michal Hocko <mhocko@suse.com>
> Cc: Mike Rapoport <rppt@kernel.org>
> Cc: Rik van Riel <riel@surriel.com>
> Cc: Shakeel Butt <shakeel.butt@linux.dev>
> Cc: Suren Baghdasaryan <surenb@google.com>
> Cc: Vlastimil Babka <vbabka@suse.cz>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> (cherry picked from commit fa04f5b60fda62c98a53a60de3a1e763f11feb41)
> Signed-off-by: Kiryl Shutsemau <kas@kernel.org>
> ---
Does not apply to 6.17.y at all :(
Did you forget to apply this on top of other commits?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 6.17.y] mm/truncate: unmap large folio on split failure
2025-11-21 9:46 ` Greg KH
@ 2025-11-21 13:20 ` Kiryl Shutsemau
2025-11-21 14:17 ` Kiryl Shutsemau
0 siblings, 1 reply; 6+ messages in thread
From: Kiryl Shutsemau @ 2025-11-21 13:20 UTC (permalink / raw)
To: Greg KH
Cc: stable, Al Viro, Baolin Wang, Christian Brauner, Darrick J. Wong,
Dave Chinner, David Hildenbrand, Hugh Dickins, Johannes Weiner,
Liam Howlett, Lorenzo Stoakes, Matthew Wilcox (Oracle),
Michal Hocko, Mike Rapoport, Rik van Riel, Shakeel Butt,
Suren Baghdasaryan, Vlastimil Babka, Andrew Morton
On Fri, Nov 21, 2025 at 10:46:11AM +0100, Greg KH wrote:
> On Thu, Nov 20, 2025 at 04:52:21PM +0000, Kiryl Shutsemau wrote:
> > Accesses within VMA, but beyond i_size rounded up to PAGE_SIZE are
> > supposed to generate SIGBUS.
> >
> > This behavior might not be respected on truncation.
> >
> > During truncation, the kernel splits a large folio in order to reclaim
> > memory. As a side effect, it unmaps the folio and destroys PMD mappings
> > of the folio. The folio will be refaulted as PTEs and SIGBUS semantics
> > are preserved.
> >
> > However, if the split fails, PMD mappings are preserved and the user will
> > not receive SIGBUS on any accesses within the PMD.
> >
> > Unmap the folio on split failure. It will lead to refault as PTEs and
> > preserve SIGBUS semantics.
> >
> > Make an exception for shmem/tmpfs that for long time intentionally mapped
> > with PMDs across i_size.
> >
> > Link: https://lkml.kernel.org/r/20251027115636.82382-3-kirill@shutemov.name
> > Fixes: b9a8a4195c7d ("truncate,shmem: Handle truncates that split large folios")
> > Signed-off-by: Kiryl Shutsemau <kas@kernel.org>
> > Cc: Al Viro <viro@zeniv.linux.org.uk>
> > Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
> > Cc: Christian Brauner <brauner@kernel.org>
> > Cc: "Darrick J. Wong" <djwong@kernel.org>
> > Cc: Dave Chinner <david@fromorbit.com>
> > Cc: David Hildenbrand <david@redhat.com>
> > Cc: Hugh Dickins <hughd@google.com>
> > Cc: Johannes Weiner <hannes@cmpxchg.org>
> > Cc: Liam Howlett <liam.howlett@oracle.com>
> > Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> > Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
> > Cc: Michal Hocko <mhocko@suse.com>
> > Cc: Mike Rapoport <rppt@kernel.org>
> > Cc: Rik van Riel <riel@surriel.com>
> > Cc: Shakeel Butt <shakeel.butt@linux.dev>
> > Cc: Suren Baghdasaryan <surenb@google.com>
> > Cc: Vlastimil Babka <vbabka@suse.cz>
> > Cc: <stable@vger.kernel.org>
> > Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> > (cherry picked from commit fa04f5b60fda62c98a53a60de3a1e763f11feb41)
> > Signed-off-by: Kiryl Shutsemau <kas@kernel.org>
> > ---
>
> Does not apply to 6.17.y at all :(
>
> Did you forget to apply this on top of other commits?
Hm. It applies cleanly on v6.17.8:
❯ git log -1 --oneline @
8ac42a63c561 (HEAD) Linux 6.17.8
❯ b4 shazam 20251120165221.892852-1-kas@kernel.org
Grabbing thread from lore.kernel.org/all/20251120165221.892852-1-kas@kernel.org/t.mbox.gz
Breaking thread to remove parents of 20251120165221.892852-1-kas@kernel.org
Checking for newer revisions
Grabbing search results from lore.kernel.org
Analyzing 2 messages in the thread
Analyzing 1 code-review messages
Checking attestation on all messages, may take a moment...
---
✓ [PATCH] mm/truncate: unmap large folio on split failure
---
✓ Signed: DKIM/kernel.org
---
Total patches: 1
---
Applying: mm/truncate: unmap large folio on split failure
Do you have anything on top of v6.17.8 in your 6.17.y queue?
My other backport to 6.17.y doesn't interfere with the patch either.
--
Kiryl Shutsemau / Kirill A. Shutemov
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 6.17.y] mm/truncate: unmap large folio on split failure
2025-11-21 13:20 ` Kiryl Shutsemau
@ 2025-11-21 14:17 ` Kiryl Shutsemau
2025-11-27 12:44 ` Greg KH
0 siblings, 1 reply; 6+ messages in thread
From: Kiryl Shutsemau @ 2025-11-21 14:17 UTC (permalink / raw)
To: Greg KH
Cc: stable, Al Viro, Baolin Wang, Christian Brauner, Darrick J. Wong,
Dave Chinner, David Hildenbrand, Hugh Dickins, Johannes Weiner,
Liam Howlett, Lorenzo Stoakes, Matthew Wilcox (Oracle),
Michal Hocko, Mike Rapoport, Rik van Riel, Shakeel Butt,
Suren Baghdasaryan, Vlastimil Babka, Andrew Morton
On Fri, Nov 21, 2025 at 01:20:08PM +0000, Kiryl Shutsemau wrote:
> On Fri, Nov 21, 2025 at 10:46:11AM +0100, Greg KH wrote:
> > On Thu, Nov 20, 2025 at 04:52:21PM +0000, Kiryl Shutsemau wrote:
> > > Accesses within VMA, but beyond i_size rounded up to PAGE_SIZE are
> > > supposed to generate SIGBUS.
> > >
> > > This behavior might not be respected on truncation.
> > >
> > > During truncation, the kernel splits a large folio in order to reclaim
> > > memory. As a side effect, it unmaps the folio and destroys PMD mappings
> > > of the folio. The folio will be refaulted as PTEs and SIGBUS semantics
> > > are preserved.
> > >
> > > However, if the split fails, PMD mappings are preserved and the user will
> > > not receive SIGBUS on any accesses within the PMD.
> > >
> > > Unmap the folio on split failure. It will lead to refault as PTEs and
> > > preserve SIGBUS semantics.
> > >
> > > Make an exception for shmem/tmpfs that for long time intentionally mapped
> > > with PMDs across i_size.
> > >
> > > Link: https://lkml.kernel.org/r/20251027115636.82382-3-kirill@shutemov.name
> > > Fixes: b9a8a4195c7d ("truncate,shmem: Handle truncates that split large folios")
> > > Signed-off-by: Kiryl Shutsemau <kas@kernel.org>
> > > Cc: Al Viro <viro@zeniv.linux.org.uk>
> > > Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
> > > Cc: Christian Brauner <brauner@kernel.org>
> > > Cc: "Darrick J. Wong" <djwong@kernel.org>
> > > Cc: Dave Chinner <david@fromorbit.com>
> > > Cc: David Hildenbrand <david@redhat.com>
> > > Cc: Hugh Dickins <hughd@google.com>
> > > Cc: Johannes Weiner <hannes@cmpxchg.org>
> > > Cc: Liam Howlett <liam.howlett@oracle.com>
> > > Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> > > Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
> > > Cc: Michal Hocko <mhocko@suse.com>
> > > Cc: Mike Rapoport <rppt@kernel.org>
> > > Cc: Rik van Riel <riel@surriel.com>
> > > Cc: Shakeel Butt <shakeel.butt@linux.dev>
> > > Cc: Suren Baghdasaryan <surenb@google.com>
> > > Cc: Vlastimil Babka <vbabka@suse.cz>
> > > Cc: <stable@vger.kernel.org>
> > > Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> > > (cherry picked from commit fa04f5b60fda62c98a53a60de3a1e763f11feb41)
> > > Signed-off-by: Kiryl Shutsemau <kas@kernel.org>
> > > ---
> >
> > Does not apply to 6.17.y at all :(
> >
> > Did you forget to apply this on top of other commits?
>
> Hm. It applies cleanly on v6.17.8:
>
> ❯ git log -1 --oneline @
> 8ac42a63c561 (HEAD) Linux 6.17.8
> ❯ b4 shazam 20251120165221.892852-1-kas@kernel.org
> Grabbing thread from lore.kernel.org/all/20251120165221.892852-1-kas@kernel.org/t.mbox.gz
> Breaking thread to remove parents of 20251120165221.892852-1-kas@kernel.org
> Checking for newer revisions
> Grabbing search results from lore.kernel.org
> Analyzing 2 messages in the thread
> Analyzing 1 code-review messages
> Checking attestation on all messages, may take a moment...
> ---
> ✓ [PATCH] mm/truncate: unmap large folio on split failure
> ---
> ✓ Signed: DKIM/kernel.org
> ---
> Total patches: 1
> ---
> Applying: mm/truncate: unmap large folio on split failure
>
> Do you have anything on top of v6.17.8 in your 6.17.y queue?
>
> My other backport to 6.17.y doesn't interfere with the patch either.
I see 6.17.9-rc1 includes
53241caf24c7 ("mm/huge_memory: do not change split_huge_page*() target order silently")
With the patch applied, fa04f5b60fda ("mm/truncate: unmap large folio on
split failure") can be cherry-picked cleanly.
--
Kiryl Shutsemau / Kirill A. Shutemov
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 6.17.y] mm/truncate: unmap large folio on split failure
2025-11-21 14:17 ` Kiryl Shutsemau
@ 2025-11-27 12:44 ` Greg KH
0 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2025-11-27 12:44 UTC (permalink / raw)
To: Kiryl Shutsemau
Cc: stable, Al Viro, Baolin Wang, Christian Brauner, Darrick J. Wong,
Dave Chinner, David Hildenbrand, Hugh Dickins, Johannes Weiner,
Liam Howlett, Lorenzo Stoakes, Matthew Wilcox (Oracle),
Michal Hocko, Mike Rapoport, Rik van Riel, Shakeel Butt,
Suren Baghdasaryan, Vlastimil Babka, Andrew Morton
On Fri, Nov 21, 2025 at 02:17:05PM +0000, Kiryl Shutsemau wrote:
> On Fri, Nov 21, 2025 at 01:20:08PM +0000, Kiryl Shutsemau wrote:
> > On Fri, Nov 21, 2025 at 10:46:11AM +0100, Greg KH wrote:
> > > On Thu, Nov 20, 2025 at 04:52:21PM +0000, Kiryl Shutsemau wrote:
> > > > Accesses within VMA, but beyond i_size rounded up to PAGE_SIZE are
> > > > supposed to generate SIGBUS.
> > > >
> > > > This behavior might not be respected on truncation.
> > > >
> > > > During truncation, the kernel splits a large folio in order to reclaim
> > > > memory. As a side effect, it unmaps the folio and destroys PMD mappings
> > > > of the folio. The folio will be refaulted as PTEs and SIGBUS semantics
> > > > are preserved.
> > > >
> > > > However, if the split fails, PMD mappings are preserved and the user will
> > > > not receive SIGBUS on any accesses within the PMD.
> > > >
> > > > Unmap the folio on split failure. It will lead to refault as PTEs and
> > > > preserve SIGBUS semantics.
> > > >
> > > > Make an exception for shmem/tmpfs that for long time intentionally mapped
> > > > with PMDs across i_size.
> > > >
> > > > Link: https://lkml.kernel.org/r/20251027115636.82382-3-kirill@shutemov.name
> > > > Fixes: b9a8a4195c7d ("truncate,shmem: Handle truncates that split large folios")
> > > > Signed-off-by: Kiryl Shutsemau <kas@kernel.org>
> > > > Cc: Al Viro <viro@zeniv.linux.org.uk>
> > > > Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
> > > > Cc: Christian Brauner <brauner@kernel.org>
> > > > Cc: "Darrick J. Wong" <djwong@kernel.org>
> > > > Cc: Dave Chinner <david@fromorbit.com>
> > > > Cc: David Hildenbrand <david@redhat.com>
> > > > Cc: Hugh Dickins <hughd@google.com>
> > > > Cc: Johannes Weiner <hannes@cmpxchg.org>
> > > > Cc: Liam Howlett <liam.howlett@oracle.com>
> > > > Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> > > > Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
> > > > Cc: Michal Hocko <mhocko@suse.com>
> > > > Cc: Mike Rapoport <rppt@kernel.org>
> > > > Cc: Rik van Riel <riel@surriel.com>
> > > > Cc: Shakeel Butt <shakeel.butt@linux.dev>
> > > > Cc: Suren Baghdasaryan <surenb@google.com>
> > > > Cc: Vlastimil Babka <vbabka@suse.cz>
> > > > Cc: <stable@vger.kernel.org>
> > > > Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> > > > (cherry picked from commit fa04f5b60fda62c98a53a60de3a1e763f11feb41)
> > > > Signed-off-by: Kiryl Shutsemau <kas@kernel.org>
> > > > ---
> > >
> > > Does not apply to 6.17.y at all :(
> > >
> > > Did you forget to apply this on top of other commits?
> >
> > Hm. It applies cleanly on v6.17.8:
> >
> > ❯ git log -1 --oneline @
> > 8ac42a63c561 (HEAD) Linux 6.17.8
> > ❯ b4 shazam 20251120165221.892852-1-kas@kernel.org
> > Grabbing thread from lore.kernel.org/all/20251120165221.892852-1-kas@kernel.org/t.mbox.gz
> > Breaking thread to remove parents of 20251120165221.892852-1-kas@kernel.org
> > Checking for newer revisions
> > Grabbing search results from lore.kernel.org
> > Analyzing 2 messages in the thread
> > Analyzing 1 code-review messages
> > Checking attestation on all messages, may take a moment...
> > ---
> > ✓ [PATCH] mm/truncate: unmap large folio on split failure
> > ---
> > ✓ Signed: DKIM/kernel.org
> > ---
> > Total patches: 1
> > ---
> > Applying: mm/truncate: unmap large folio on split failure
> >
> > Do you have anything on top of v6.17.8 in your 6.17.y queue?
> >
> > My other backport to 6.17.y doesn't interfere with the patch either.
>
> I see 6.17.9-rc1 includes
>
> 53241caf24c7 ("mm/huge_memory: do not change split_huge_page*() target order silently")
>
> With the patch applied, fa04f5b60fda ("mm/truncate: unmap large folio on
> split failure") can be cherry-picked cleanly.
Ah, that worked, thanks!
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-11-27 12:44 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-20 16:13 FAILED: patch "[PATCH] mm/truncate: unmap large folio on split failure" failed to apply to 6.17-stable tree gregkh
2025-11-20 16:52 ` [PATCH 6.17.y] mm/truncate: unmap large folio on split failure Kiryl Shutsemau
2025-11-21 9:46 ` Greg KH
2025-11-21 13:20 ` Kiryl Shutsemau
2025-11-21 14:17 ` Kiryl Shutsemau
2025-11-27 12:44 ` Greg KH
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.