mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "David Hildenbrand (Arm)" <david@kernel.org>
To: "Jose A. Perez de Azpillaga" <azpijr@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Shuah Khan <shuah@kernel.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>,
	"Liam R. Howlett" <liam@infradead.org>,
	Vlastimil Babka <vbabka@kernel.org>,
	Mike Rapoport <rppt@kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	Michal Hocko <mhocko@suse.com>,
	linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] selftests/mm: check MREMAP_DONTUNMAP mlock accounting
Date: Mon, 28 Sep 2026 14:08:51 +0200	[thread overview]
Message-ID: <ae606df5-7d14-47b4-8569-fe47321bfac7@kernel.org> (raw)
In-Reply-To: <20260928111055.482136-1-azpijr@gmail.com>

On 9/28/26 13:10, Jose A. Perez de Azpillaga wrote:
> MREMAP_DONTUNMAP keeps the source VMA in place, but clears its mlock flags
> for the whole VMA while setting them on the destination VMA.  Two cases
> leak mm->locked_vm as a result:
> 
>  - an unfaulted mlock-on-fault VMA moved behind itself self-merges, so the
>    single resulting VMA loses the flags without the accounting being
>    dropped;
> 
>  - a partial mremap() moves only part of the range, leaving the pages which
>    are not moved accounted as locked in a VMA whose flags were cleared.
> 
> Add three cases to the MREMAP_DONTUNMAP selftest which mlock() the source
> VMA, with and without MLOCK_ONFAULT, perform the operation and check that
> VmLck comes back to zero once everything is unmapped.  Each case runs in
> its own process, so it starts from a clean mm with VmLck at zero and a
> failure cannot propagate to the cases which follow.
> 
> Verified on x86_64: the three cases fail on v7.3-rc5 and pass on
> mm-unstable with the fixes from the "mm/mremap: fix two issues with
> MREMAP_DONTUNMAP" series applied.
> 
> Signed-off-by: Jose A. Perez de Azpillaga <azpijr@gmail.com>
> ---
>  tools/testing/selftests/mm/mremap_dontunmap.c | 273 +++++++++++++++++-

@Lorenzo, could something like this also be implemented (maybe with less churn)
in the vma.c selftests?

-- 
Cheers,

David

  reply	other threads:[~2026-09-28 12:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-28 11:10 Jose A. Perez de Azpillaga
2026-09-28 12:08 ` David Hildenbrand (Arm) [this message]
2026-09-28 12:17   ` 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=ae606df5-7d14-47b4-8569-fe47321bfac7@kernel.org \
    --to=david@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=azpijr@gmail.com \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=rppt@kernel.org \
    --cc=shuah@kernel.org \
    --cc=surenb@google.com \
    --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

all inboxes | Powered by JetHome®