linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Peter Xu <peterx@redhat.com>
Cc: Lokesh Gidra <lokeshgidra@google.com>,
	Suren Baghdasaryan <surenb@google.com>,
	akpm@linux-foundation.org, viro@zeniv.linux.org.uk,
	brauner@kernel.org, shuah@kernel.org, aarcange@redhat.com,
	hughd@google.com, mhocko@suse.com, axelrasmussen@google.com,
	rppt@kernel.org, willy@infradead.org, Liam.Howlett@oracle.com,
	jannh@google.com, zhangpeng362@huawei.com, bgeffon@google.com,
	kaleshsingh@google.com, ngeoffray@google.com, jdduke@google.com,
	linux-mm@kvack.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	kernel-team@android.com
Subject: Re: [PATCH v3 2/3] userfaultfd: UFFDIO_MOVE uABI
Date: Thu, 19 Oct 2023 17:41:01 +0200	[thread overview]
Message-ID: <d40b8c86-6163-4529-ada4-d2b3c1065cba@redhat.com> (raw)
In-Reply-To: <ZS7ZqztMbhrG52JQ@x1n>

On 17.10.23 20:59, Peter Xu wrote:
> David,
> 
> On Tue, Oct 17, 2023 at 05:55:10PM +0200, David Hildenbrand wrote:
>> Don't get me wrong, but this feature is already complicated enough that we
>> should really think twice if we want to make this even more complicated and
>> harder to maintain -- because once it's in we all know it's hard to remove
>> and we can easily end up with a maintenance nightmare without sufficiently
>> good use cases.
> 
> Yes I agree it's non-trivial.  My point is adding cross-mm doesn't make it
> even more complicated.. afaics.

That's not my main point. It can easily become a maintenance burden 
without any real use cases yet that we are willing to support.

> 
> For example, could you provide a list of things that will be different to
> support single mm or cross mm?  I see two things that can be different, but
> I'd rather have all of them even if single-mm..
> 
>    - cgroup: I assume single-mm may avoid uncharge and charge again, but I
>      prefer it be there even if we only allow single-mm.  For example, I'm
>      not 100% sure whether memcg won't start to behave differently according
>      to vma attribute in the future.
> 
>    - page pinning: I assume for single-mm we can avoid checking page pinning
>      based on the fact that MMF_HAS_PINNED is per-mm, but I also prefer we
>      fail explicitly on pinned pages over UFFDIO_MOVE because it doesn't
>      sound correct, and avoid future changes on top of pinning solution that
>      can change the assumption that "move a pin page within mm" is ok.
> 
> Is there anything else that will be different?  Did I miss something
> important?

Again, that's not my main point. All I'm asking for is to separate it 
out, make it a separate flag, and include it once we have reasonable use 
cases that we are actually willing to support -- including actual data 
why it's beneficial to have.

For the single-mm use it has been shown that there are reasonable, 
existing use cases exist, and I think we are willing to support that.

This patch set is close to doubling (!) the size of mm/userfaultfd.c, 
and it already has every possible smell of maintanance nightmare IMHO. 
It does things that shouldn't be specific to some MM subsystem. I'm 
happy to see any possible complexity reduced. Moving pages between MMs 
is added complexity.

But I will stop arguing further; I hope I made my point clear and I have 
other things to work on than fighting against overly-complicated uffd 
features.


> 
> [...]
> 
>> BTW, wasn't there a way to do VM live-upgrade using fork() and replacing the
>> binary? I recall that there was at some time either an implementation in
>> QEMU or a proposal for an implementation; but I don't know how VM memory was
>> provided. It's certainly harder to move VM memory using fork().
> 
> Maybe you meant the cpr project.  I didn't actually follow that much
> previously (and will need to follow more after I took the migration
> duties.. when there's a new post), but IIUC at least the latest version
> needs to go with file memory only, not anonymous:
> 
> https://lore.kernel.org/all/1658851843-236870-1-git-send-email-steven.sistare@oracle.com/
> 
>          Guest RAM must be non-volatile across reboot, which can be achieved by
>          backing it with a dax device, or /dev/shm PKRAM as proposed in...
> 
>          Guest RAM must be backed by a memory backend with share=on, but
>          cannot be memory-backend-ram.  The memory is re-mmap'd in the
>          updated process, so guest ram is efficiently preserved in place
> 
> My understanding is there used to have solution for anonymous but that
> needs extra kernel changes (MADV_DOEXEC).

Probably, I also stumbled over a paper from 2019 that mentioned that that.

> 
> https://lore.kernel.org/linux-mm/1595869887-23307-1-git-send-email-anthony.yznaga@oracle.com/
> 
> I saw that you were part of the discussion, so maybe you will remember some
> more clue of that part.
> 

Ouch, 2020. But my comments were only regarding mshare, not MADV_DOEXEC. 
In fact, I don't even know why both discussions/threads show up as a 
single one there..

> IIUC one core requirement of the whole approach is also that it will cover
> VFIO and maintenance of device DMA mappings, in which case it'll be
> different with any approach to leverage UFFDIO_MOVE because VFIO will not
> be allowed here; again I hope we start with forbid pinning. But it should
> be much cleaner on the design when with UFFDIO_MOVE, just not working with
> VFIO.
> 
> One thing I'd need to measure is latency of UFFDIO_MOVE on page fault
> resolutions.  I expect no more than tens of microseconds or even less.
> Should be drastically smaller than remote postcopy anyway.
> 
> I'm probably off topic.. To go back: let's try to figure out what is
> special with cross-mm support.  It'll be very weird in the future for
> anyone to propose a patch just add a feature flag and declaring cross-mm
> support, if the code is mostly all there.  Nothing stops us from discussing
> what a cross-mm design will need.

Again, I hope I made my point clear.

> 
> [...]
> 
>> Is that and will that remain the case? I know people have been working on
>> transparent user-space swapping using monitor processes using uffd. I
>> thought there would have been ways to achieve that without any corporation
>> of the dst.
> 
> Any example?

Nothing concrete, I only heard about uffd monitors that implement 
user-space based swapping. I don't recall if they require some kind of 
support from a library that gets loaded into these processes,

Same thoughts regarding CRIU using uffd.

> 
> For what I am aware, all corporation requires uffd desc forwarding.  I
> think the trick here is any userfaultfd desc must be created by its own
> process, so far nobody else.  That's more or less saying "I want to do
> this" from its own opinion.  The next is forwarding that to someone else.
> Parent process is fine taking uffd of child with EVENT_FORK, as I
> mentioned, but besides that nothing else I can think of that can violate
> this guard to manipulate a random process.

Do you have any idea how CRIU makes that work (at least I recall that 
they wanted to use UFFD).

-- 
Cheers,

David / dhildenb



  reply	other threads:[~2023-10-19 15:41 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-09  6:42 [PATCH v3 0/3] userfaultfd move option Suren Baghdasaryan
2023-10-09  6:42 ` [PATCH v3 1/3] mm/rmap: support move to different root anon_vma in folio_move_anon_rmap() Suren Baghdasaryan
2023-10-12 22:01   ` Peter Xu
2023-10-13  8:04     ` David Hildenbrand
2023-10-19 15:19       ` Suren Baghdasaryan
2023-10-09  6:42 ` [PATCH v3 2/3] userfaultfd: UFFDIO_MOVE uABI Suren Baghdasaryan
2023-10-09 14:38   ` David Hildenbrand
2023-10-09 16:21     ` Suren Baghdasaryan
2023-10-09 16:23       ` David Hildenbrand
2023-10-09 16:29         ` Lokesh Gidra
2023-10-09 17:56           ` Lokesh Gidra
2023-10-10  1:49             ` Suren Baghdasaryan
2023-10-12 20:11           ` Peter Xu
2023-10-13  9:56             ` David Hildenbrand
2023-10-13 16:08               ` Peter Xu
2023-10-13 16:49                 ` Lokesh Gidra
2023-10-13 17:05                   ` Peter Xu
2023-10-16 18:01                 ` David Hildenbrand
2023-10-16 19:01                   ` Peter Xu
2023-10-17 15:55                     ` David Hildenbrand
2023-10-17 18:59                       ` Peter Xu
2023-10-19 15:41                         ` David Hildenbrand [this message]
2023-10-19 19:53                           ` Peter Xu
2023-10-19 20:02                             ` Suren Baghdasaryan
2023-10-19 20:43                               ` Peter Xu
2023-10-20 10:02                             ` David Hildenbrand
2023-10-20 14:09                               ` Suren Baghdasaryan
2023-10-20 17:16                                 ` David Hildenbrand
2023-10-22 15:46                                   ` Peter Xu
2023-10-23 12:03                                     ` David Hildenbrand
2023-10-23 16:36                                       ` David Hildenbrand
2023-10-23 17:33                                         ` Suren Baghdasaryan
2023-10-19 21:45                 ` Suren Baghdasaryan
2023-10-12 21:59   ` Peter Xu
2023-10-19 21:24     ` Suren Baghdasaryan
2023-10-22 17:01       ` Peter Xu
2023-10-23 17:43         ` Suren Baghdasaryan
2023-10-23 18:37           ` Peter Xu
2023-10-23 19:01             ` Suren Baghdasaryan
2023-10-17 19:39   ` kernel test robot
2023-10-19 21:55     ` Suren Baghdasaryan
2023-10-23 12:29   ` David Hildenbrand
2023-10-23 15:53     ` David Hildenbrand
2023-10-23 19:00       ` Suren Baghdasaryan
2023-10-23 18:56     ` Suren Baghdasaryan
2023-10-24 14:27       ` David Hildenbrand
2023-10-24 14:36         ` Suren Baghdasaryan
2023-10-09  6:42 ` [PATCH v3 3/3] selftests/mm: add UFFDIO_MOVE ioctl test Suren Baghdasaryan
2023-10-12 22:29   ` Peter Xu
2023-10-19 15:43     ` Suren Baghdasaryan
2023-10-19 17:29       ` Axel Rasmussen
2023-10-19 19:33         ` Peter Xu

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=d40b8c86-6163-4529-ada4-d2b3c1065cba@redhat.com \
    --to=david@redhat.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=axelrasmussen@google.com \
    --cc=bgeffon@google.com \
    --cc=brauner@kernel.org \
    --cc=hughd@google.com \
    --cc=jannh@google.com \
    --cc=jdduke@google.com \
    --cc=kaleshsingh@google.com \
    --cc=kernel-team@android.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lokeshgidra@google.com \
    --cc=mhocko@suse.com \
    --cc=ngeoffray@google.com \
    --cc=peterx@redhat.com \
    --cc=rppt@kernel.org \
    --cc=shuah@kernel.org \
    --cc=surenb@google.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    --cc=zhangpeng362@huawei.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;
as well as URLs for NNTP newsgroup(s).