From: David Hildenbrand <david@redhat.com>
To: Barry Song <21cnbao@gmail.com>
Cc: aarcange@redhat.com, akpm@linux-foundation.org,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
lokeshgidra@google.com, peterx@redhat.com, ryncsn@gmail.com,
surenb@google.com
Subject: Re: [BUG]userfaultfd_move fails to move a folio when swap-in occurs concurrently with swap-out
Date: Tue, 27 May 2025 13:06:42 +0200 [thread overview]
Message-ID: <42ce8dcc-0139-4dd7-9bef-bf3efa93849a@redhat.com> (raw)
In-Reply-To: <CAGsJ_4xQ4-bszHNi=0QDCqsap+0WdfU9_u8ftaMuKCuNcn8RYA@mail.gmail.com>
>>
>> EBUSY
>> The pages in the source virtual memory range are either
>> pinned or not exclusive to the process. The kernel might
>> only perform lightweight checks for detecting whether the
>> pages are exclusive. To make the operation more likely to
>> succeed, KSM should be disabled, fork() should be avoided
>> or MADV_DONTFORK should be configured for the source
>> virtual memory area before fork().
>>
>> Note the "lightweight" and "more likely to succeed".
>>
>
> Initially, my point was that an exclusive folio (single-process case)
> should be movable.
Yeah, I would wish that we wouldn't need that PAE hack in the swapin code.
I was asking myself if we could just ... wait for writeback to end in
that case?
I mean, if we would have to swap in the folio we would also have to wait
for disk I/O ... so here we would also have to wait for disk I/O.
We could either wait for writeback before mapping the folio, or set the
PAE bit and map the page R/O, to then wait for writeback during write
faults.
The latter has the downside that we have to handle it with more
complexity during write faults (check if page is under writeback, then
check if we require this sync I/O during write faults even though PAE is
set ...).
> Now I understand this isn’t a bug, but rather a compromise made due
> to implementation constraints.
That is a good summary!
> Perhaps the remaining value of this report is that it helped better
> understand scenarios beyond fork where a move might also fail.
>
> I truly appreciate your time and your clear analysis.
YW :)
--
Cheers,
David / dhildenb
prev parent reply other threads:[~2025-05-27 11:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-22 23:23 Barry Song
2025-05-22 23:43 ` Lokesh Gidra
2025-05-22 23:53 ` Barry Song
2025-05-23 0:03 ` Lokesh Gidra
2025-05-26 12:39 ` David Hildenbrand
2025-05-27 4:17 ` Barry Song
2025-05-27 8:37 ` Barry Song
2025-05-27 9:00 ` David Hildenbrand
2025-05-27 9:31 ` Barry Song
2025-05-27 11:06 ` David Hildenbrand [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=42ce8dcc-0139-4dd7-9bef-bf3efa93849a@redhat.com \
--to=david@redhat.com \
--cc=21cnbao@gmail.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lokeshgidra@google.com \
--cc=peterx@redhat.com \
--cc=ryncsn@gmail.com \
--cc=surenb@google.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