From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
To: Josef Bacik <josef@toxicpanda.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
"Liam R. Howlett" <liam@infradead.org>,
David Hildenbrand <david@kernel.org>,
Vlastimil Babka <vbabka@kernel.org>,
Jann Horn <jannh@google.com>, Pedro Falcato <pfalcato@suse.de>,
Muchun Song <muchun.song@linux.dev>,
Oscar Salvador <osalvador@suse.de>,
linux-mm@kvack.org, stable@vger.kernel.org
Subject: Re: [PATCH 0/6] mm/mremap: report a failed split before moving anything
Date: Mon, 2 Nov 2026 12:50:27 +0000 [thread overview]
Message-ID: <auiGqsbwuRhIfhvj@gremlin> (raw)
In-Reply-To: <20261030-b4-mremap-pre-split-v1-0-c1829811aed0@toxicpanda.com>
On Fri, Oct 30, 2026 at 02:42:45PM +0000, Josef Bacik wrote:
> Hello,
>
> I went through the callers of __split_vma() to see who can't cope with
> it failing, and mremap() is the bad one. If you move part of a VMA we
Yeah, what's frustrating there is that, AFAICT, the only really relevant
case is DAX.
But maybe hugetlb somehow raises its ugly head as you allude to.
> don't split it until the very end, when we unmap the old range. By then
> the page tables have moved and there's nothing to go back to, so we fix
> up the accounting and return success with the old range still mapped.
>
> Lorenzo recently added a way to split ahead of the move for the mlock()
> + MREMAP_DONTUNMAP case. This series uses that for every move that
MREMAP_DONTUNMAP is another real horror show for bugs. Candidate for
'should have never been merged'...
> unmaps its source, so a split that fails is reported before we've done
> anything.
>
> Doing that turned up a real bug in hugetlb. We take the reservation map
> away from the whole old VMA before the part that's moving is split off,
> so the parts that stay never give their reservations back. That fix is
> the first patch so it can go to stable by itself, and the second patch
> is a selftest for it.
>
> The next two fix the accounting for when the unmap at the end does fail,
> we either charged memory that was never accounted or lost track of the
> charge for the whole VMA. That gets a lot harder to hit with the last
> patch but it's still possible. There's also a test for an old size of
> 0, which nothing covered.
I feel like the charging logic needs to be reworked anyway. This whole
'drop VMA_ACCOUNT_BIT' hack is extremely stupid.
>
> I tested this with the mm selftests and with a loop that fails each
> allocation inside mremap() in turn and checks that we either moved or
> didn't. The numbers for moving part of a mapping don't change. Thanks,
>
> Josef
Anyway, thanks for these, will go through.
>
> ---
> Josef Bacik (6):
> mm/mremap: fix hugetlb reservation leak on partial move
> selftests/mm: test a partial mremap() of hugetlb memory
> mm/mremap: reaccount on unmap failure only if accounted
> mm/mremap: restore VM_ACCOUNT if the unmap fails
> selftests/mm: test mremap() with an old size of 0
> mm/mremap: split first so a failed split is reported
>
> mm/mremap.c | 55 +++++++++++++++++++++++------
> tools/testing/selftests/mm/hugetlb-mremap.c | 52 +++++++++++++++++++++++++--
> tools/testing/selftests/mm/mremap_test.c | 52 ++++++++++++++++++++++++++-
> 3 files changed, 145 insertions(+), 14 deletions(-)
> ---
> base-commit: cd1d0b147afa81f80927f9711e53401703964217
> change-id: 20261030-b4-mremap-pre-split-13a3d54d6dbd
>
--
Cheers, Lorenzo
prev parent reply other threads:[~2026-11-02 12:50 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-30 14:42 [PATCH 0/6] mm/mremap: report a failed split before moving anything Josef Bacik
2026-10-30 14:42 ` [PATCH 1/6] mm/mremap: fix hugetlb reservation leak on partial move Josef Bacik
2026-11-02 13:13 ` Lorenzo Stoakes (ARM)
2026-10-30 14:42 ` [PATCH 2/6] selftests/mm: test a partial mremap() of hugetlb memory Josef Bacik
2026-11-02 13:14 ` Lorenzo Stoakes (ARM)
2026-10-30 14:42 ` [PATCH 3/6] mm/mremap: reaccount on unmap failure only if accounted Josef Bacik
2026-11-02 13:17 ` Lorenzo Stoakes (ARM)
2026-10-30 14:42 ` [PATCH 4/6] mm/mremap: restore VM_ACCOUNT if the unmap fails Josef Bacik
2026-11-02 13:38 ` Lorenzo Stoakes (ARM)
2026-10-30 14:42 ` [PATCH 5/6] selftests/mm: test mremap() with an old size of 0 Josef Bacik
2026-11-02 13:39 ` Lorenzo Stoakes (ARM)
2026-10-30 14:42 ` [PATCH 6/6] mm/mremap: split first so a failed split is reported Josef Bacik
2026-10-31 19:27 ` Jose A. Perez de Azpillaga
2026-11-02 13:57 ` Lorenzo Stoakes (ARM)
2026-11-02 12:50 ` Lorenzo Stoakes (ARM) [this message]
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=auiGqsbwuRhIfhvj@gremlin \
--to=ljs@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=jannh@google.com \
--cc=josef@toxicpanda.com \
--cc=liam@infradead.org \
--cc=linux-mm@kvack.org \
--cc=muchun.song@linux.dev \
--cc=osalvador@suse.de \
--cc=pfalcato@suse.de \
--cc=stable@vger.kernel.org \
--cc=vbabka@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