From: "Jose A. Perez de Azpillaga" <azpijr@gmail.com>
To: Josef Bacik <josef@toxicpanda.com>,
Andrew Morton <akpm@linux-foundation.org>,
Lorenzo Stoakes <ljs@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
David Hildenbrand <david@kernel.org>
Cc: 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
Subject: Re: [PATCH v2 4/5] mm/mremap: restore VMA_ACCOUNT_BIT if the unmap fails
Date: Tue, 3 Nov 2026 12:08:36 +0100 [thread overview]
Message-ID: <9ffda863-507e-4911-8d4e-dbb7f0e26544@gmail.com> (raw)
In-Reply-To: <20261102-b4-mremap-pre-split-v2-4-d281dd11ad7d@toxicpanda.com>
On 11/3/26 12:46 AM, Josef Bacik wrote:
> If the unmap at the end of an mremap() move fails, the source VMA stays
> without VMA_ACCOUNT_BIT. Neither munmap() nor exit_mmap() uncharges it
> then, so the charge for all of its pages stays in vm_committed_as after
> the process is gone.
>
> unmap_source_vma() clears the flag on the whole source VMA before the unmap
> and sets it again on the remaining parts afterwards, but its error path
> returns without doing so.
>
> This was reproduced with fault injection: each failure on an anonymous
> mapping left Committed_AS higher by the size of the whole VMA after
> everything was unmapped.
>
> Fix by setting the flag again on everything in the range of the original
> VMA, on both paths, with a new helper. A failed unmap may have split the
> VMA already, so the helper walks the range.
>
> Fixes: 51df7bcb6151 ("mm/mremap: account memory on do_munmap() failure")
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
nice!
Reviewed-by: Jose A. Perez de Azpillaga <azpijr@gmail.com>
--
cheers,
jose a. p-a
next prev parent reply other threads:[~2026-11-03 11:08 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 23:45 [PATCH v2 0/5] mm/mremap: fix accounting on a partial move Josef Bacik
2026-11-02 23:45 ` [PATCH v2 1/5] mm/mremap: fix hugetlb reservation leak on " Josef Bacik
2026-11-03 10:42 ` Jose A. Perez de Azpillaga
2026-11-02 23:45 ` [PATCH v2 2/5] selftests/mm: test a partial mremap() of hugetlb memory Josef Bacik
2026-11-03 10:48 ` Jose A. Perez de Azpillaga
2026-11-02 23:45 ` [PATCH v2 3/5] mm/mremap: reaccount on unmap failure only if accounted Josef Bacik
2026-11-03 10:53 ` Jose A. Perez de Azpillaga
2026-11-02 23:46 ` [PATCH v2 4/5] mm/mremap: restore VMA_ACCOUNT_BIT if the unmap fails Josef Bacik
2026-11-03 8:31 ` Lorenzo Stoakes (ARM)
2026-11-03 11:08 ` Jose A. Perez de Azpillaga [this message]
2026-11-02 23:46 ` [PATCH v2 5/5] selftests/mm: test mremap() with an old size of 0 Josef Bacik
2026-11-03 11:27 ` Jose A. Perez de Azpillaga
2026-11-04 5:40 ` Sarthak Sharma
2026-11-03 0:23 ` [PATCH v2 0/5] mm/mremap: fix accounting on a partial move Andrew Morton
2026-11-04 14:32 ` Josef Bacik
2026-11-04 14:46 ` Lorenzo Stoakes (ARM)
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=9ffda863-507e-4911-8d4e-dbb7f0e26544@gmail.com \
--to=azpijr@gmail.com \
--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=ljs@kernel.org \
--cc=muchun.song@linux.dev \
--cc=osalvador@suse.de \
--cc=pfalcato@suse.de \
--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 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.