From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Joanne Koong <joannelkoong@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Kiryl Shutsemau <kas@kernel.org>,
Usama Arif <usama.arif@linux.dev>, Barry Song <baohua@kernel.org>,
Lance Yang <lance.yang@linux.dev>,
Lorenzo Stoakes <ljs@kernel.org>, Rik van Riel <riel@surriel.com>,
"Liam R . Howlett" <liam@infradead.org>,
Vlastimil Babka <vbabka@kernel.org>, Harry Yoo <harry@kernel.org>,
Jann Horn <jannh@google.com>, Zi Yan <ziy@nvidia.com>,
SJ Park <sj@kernel.org>, Johannes Weiner <hannes@cmpxchg.org>,
linux-mm@kvack.org, Sashiko <sashiko-bot@kernel.org>,
azpijr@gmail.com
Subject: Re: [PATCH v1] mm/rmap: fix migration entries being treated as partial unmaps
Date: Sun, 22 Nov 2026 17:11:48 +0100 [thread overview]
Message-ID: <4a017c79-db13-4fe7-8161-36400596fd6c@kernel.org> (raw)
In-Reply-To: <CAJnrk1YWf=rJc2uB-sCwxSVFa8KperRn30bJ3m_1Q-026P68BQ@mail.gmail.com>
On 11/14/26 00:51, Joanne Koong wrote:
> On Fri, Nov 13, 2026 at 11:23 AM David Hildenbrand (Arm)
> <david@kernel.org> wrote:
>>
>> On 11/13/26 00:28, Joanne Koong wrote:
>>> On Tue, Nov 10, 2026 at 3:49 AM David Hildenbrand (Arm)
>>> <david@kernel.org> wrote:
>>>
>>> As I understand it, there's no simple way to check if a folio is
>>> partially mapped or not under CONFIG_NO_PAGE_MAPCOUNT without doing a
>>> rmap walk.
>>
>> Yes. With CONFIG_PAGE_MAPCOUNT you can (still) read the information from the
>> folio, but the grand plan is to phase that out and remove it.
>>
>> I just keep getting distracted :)
>>
>>> Would it make sense to do something simpler here instead
>>> where we just check the folio's partially mapped flag and cache that
>>> before we replace the PTEs with migration entries, and then for those
>>> edge cases that the batching solution doesn't cover, just restore that
>>> flag back to its original state?
>>
>> As a last resort if we cannot get something else working (and we really care).
>> It is rather hacky.
>>
>>>
>>> I think this would add coverage for the migration and reclaim paths,
>>> instead of just the deferred split shrinker, but would miss the race
>>> where someone tries to do a partial unmap while the folio has the
>>> migration PTEs, but I think this is already a race that exists in the
>>> batching case. imo it seems acceptable though given that the race is
>>> pretty rare and doesn't have any adverse effects except delaying
>>> freeing the unmapped pages until the whole folio gets unmapped.
>>>
>>> Do you think something like this makes sense, or would you prefer
>>> having the check in the deferred split handler?
>>
>> The question is, do we really care once we have the PTE batching in place?
>>
>> We would still split for if we cannot batch (multiple VMAs, PTE differences that
>> we have to respect). Do we have any idea how much that matters in practice?
>>
>> (I raised once that, just because a folio is fully mapped doesn't really telly
>> you anything. It could be mapped into various processes partially, or scattered
>> in a single process.)
>>
>
> Sounds good! I'll put this on hold until it's proven to actually be
> needed after Shivank's series.
Thinking again, just saying "we're unmapping for migration, so just don't mess
with partial mapped state" through a new rmap flag that we pass does sound
reasonable.
But ideally this flag would have an abstracted meaning (e.g., this is temporary
system-triggered unmap due to migration/split/swapout/whatever) and not some
thing concrete like "defer split".
Yes, we'll not handle when someone actually triggers partial unmapping at the
same time by doing MADV_DONTNEED etc. But I guess we shouldn't worry about that
for now.
Doing the folio PTE batching still makes sense.
--
Cheers,
David
next prev parent reply other threads:[~2026-11-22 16:12 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 22:09 [PATCH v1] mm/rmap: fix migration entries being treated as partial unmaps Joanne Koong
2026-11-10 11:48 ` David Hildenbrand (Arm)
2026-11-10 20:21 ` Joanne Koong
2026-11-10 20:55 ` David Hildenbrand (Arm)
2026-11-10 21:05 ` Zi Yan
2026-11-10 23:26 ` Joanne Koong
2026-11-12 23:28 ` Joanne Koong
2026-11-13 19:23 ` David Hildenbrand (Arm)
2026-11-13 23:51 ` Joanne Koong
2026-11-22 16:11 ` David Hildenbrand (Arm) [this message]
2026-11-10 22:13 ` sashiko-bot
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=4a017c79-db13-4fe7-8161-36400596fd6c@kernel.org \
--to=david@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=azpijr@gmail.com \
--cc=baohua@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=harry@kernel.org \
--cc=jannh@google.com \
--cc=joannelkoong@gmail.com \
--cc=kas@kernel.org \
--cc=lance.yang@linux.dev \
--cc=liam@infradead.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=riel@surriel.com \
--cc=sashiko-bot@kernel.org \
--cc=sj@kernel.org \
--cc=usama.arif@linux.dev \
--cc=vbabka@kernel.org \
--cc=ziy@nvidia.com \
/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