Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp442839rdb; Thu, 19 Oct 2023 08:42:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGOqS2ids7SmL08eOfNvvq3LR0Avr/xTfa6TK4f+EA+pm1+RE/s2PWUELiXWoASrKk1tetC X-Received: by 2002:a05:6a20:1453:b0:159:e4ab:15ce with SMTP id a19-20020a056a20145300b00159e4ab15cemr3277359pzi.15.1697730164366; Thu, 19 Oct 2023 08:42:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697730164; cv=none; d=google.com; s=arc-20160816; b=dZG6rmndD4HDdTsoC9WFG4Ns0XM7OF8pgV3mSLsSW4MGJvOQr0H8bPe7pusf54Unzy YHCLAbKR09JuBj8pE5tQGqzy8HlREtRpeNvqof+ZanA4RrBSFZzEMPjUm2tQUO/pf5Fv /kX1nmvs1FNATZLSnhvG59mgmFD9ADwl2xO5cjIB/6c2SCDeAC7meBpJADCXXUM6ArJk uMaenDMlvYZkNb5QCzgEynQhZl5VmlZaedBiLth1HXvV4d+nhxEZ3uKf8INcXMSOhGax f0XllgmI3sKuUAzW6BcEnrKkf8meefoxlqRg8eEI4/ZyhAP7gy13IpBBJlEbP6PXKr7e AAkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:autocrypt:from:references:cc:to:content-language :subject:user-agent:mime-version:date:message-id:dkim-signature; bh=JJr/PRGCFlMD3E/uH7FWSeqfLKgpGGhQWrbZ5EJs+i0=; fh=DF6IzoS/d82hvLmWh7wD8eqUJ9CUirRGB+KPPUNJ1FU=; b=dghIHtKhRM2om7wmHb/TKPILVUnmb0CkPev7kEaNQj6ew5xUPghiyBDaHeyPIEeGjj P7RiTb8lDE3IlXXX0mzptjgAM5NLrR+PVMyimrDC9GdYuhZfSIS+pGMyVcLvBsVggDiG FakNe4c8QTCdhG6tL0AtO3ZYPIhwii3O15A7ggjfQNlnNUoYO+Kj8+jOK/uaCuEd2XU0 lIioGDwu+AFJpu+U9c3gevmzM3jjnN1ulFoLlAXuyQcu7B1tH7CpRXWa0Lr9tUYrTzO3 JcKNtc/MJwE3d8PUE4pId9TGM6OY1NSpmhartUNayFwEFJhZk7YYF/OX0WO78lVFqtHw dvwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SchFUOns; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id be3-20020a656e43000000b00578b9fb24f3si4469892pgb.633.2023.10.19.08.42.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 08:42:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SchFUOns; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 2F7228239B96; Thu, 19 Oct 2023 08:42:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346360AbjJSPmB (ORCPT + 99 others); Thu, 19 Oct 2023 11:42:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346434AbjJSPlz (ORCPT ); Thu, 19 Oct 2023 11:41:55 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85E4C12A for ; Thu, 19 Oct 2023 08:41:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697730068; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=JJr/PRGCFlMD3E/uH7FWSeqfLKgpGGhQWrbZ5EJs+i0=; b=SchFUOnsP32TyKsFDvyqGsW7ZyQVISl9Fxqb8osC7vy37ECDsFVIjqp4cPpC9W89tjvjLX 9lXFLXknGdyNd5RrVR88nuEIOMv1HI7dONdlFu6K1A0RZVBnK44XXots0uFkDHSX5wxryG VLotnSS0mEj2RbFzRd7AmzYYJkhQQcQ= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-36-Gu5n9FShP86IAIXUJigf3w-1; Thu, 19 Oct 2023 11:41:05 -0400 X-MC-Unique: Gu5n9FShP86IAIXUJigf3w-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-406de77fb85so50636285e9.0 for ; Thu, 19 Oct 2023 08:41:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697730064; x=1698334864; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=JJr/PRGCFlMD3E/uH7FWSeqfLKgpGGhQWrbZ5EJs+i0=; b=j807HmUoNvRSxpTb8UoFIIlNzo6/2OHxBzPTfvqiIv0HM4CV7Wh1QTvsJsVqkvBO/j cm2MP0acHuoAnRjTyQWIO+htWm3wGxOZHDb41ne0lEIdy39EIhmzheoDDJnJtfJrFxoV uImLaZDjLaErvQbQ1Icxw/yPbRQcEIP+hXkBi9E+KlcKzIZmlqwMOPzBSv9vMGnosKle El7thAsJ3Sjlsqb1qeeGv5+OjHNwq41pSWrHWWduzhS51eN8czJgrBhvno4TyNlBCnaj UghWgElhl/3LjF1xINQrxU7WYCt+jtLt7Ct+KxJSnd4ylDmhVhGj60V2djvPra+c2ndk bJWw== X-Gm-Message-State: AOJu0YxMSnZcJKFC7cwfkyBPd0IwmpY3uaR9xOpwNrYTX2Ten7wshca7 HR950Zzwr4a61pL/lv4NQCnS9k4uPOxOezFKXDjX6Obl+WLQ66C1yurMKUEfvoHDpV3nr72RLVL YGJOKvQ01o59UYkQ2l7fKhWIQ X-Received: by 2002:a05:600c:4592:b0:408:2686:e1cb with SMTP id r18-20020a05600c459200b004082686e1cbmr1998641wmo.23.1697730063996; Thu, 19 Oct 2023 08:41:03 -0700 (PDT) X-Received: by 2002:a05:600c:4592:b0:408:2686:e1cb with SMTP id r18-20020a05600c459200b004082686e1cbmr1998620wmo.23.1697730063400; Thu, 19 Oct 2023 08:41:03 -0700 (PDT) Received: from ?IPV6:2003:cb:c70b:500:6a06:17fc:810b:b054? (p200300cbc70b05006a0617fc810bb054.dip0.t-ipconnect.de. [2003:cb:c70b:500:6a06:17fc:810b:b054]) by smtp.gmail.com with ESMTPSA id x9-20020a05600c420900b004065e235417sm4630990wmh.21.2023.10.19.08.41.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 19 Oct 2023 08:41:02 -0700 (PDT) Message-ID: Date: Thu, 19 Oct 2023 17:41:01 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 2/3] userfaultfd: UFFDIO_MOVE uABI Content-Language: en-US To: Peter Xu Cc: Lokesh Gidra , Suren Baghdasaryan , 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 References: <214b78ed-3842-5ba1-fa9c-9fa719fca129@redhat.com> <478697aa-f55c-375a-6888-3abb343c6d9d@redhat.com> <205abf01-9699-ff1c-3e4e-621913ada64e@redhat.com> <12588295-2616-eb11-43d2-96a3c62bd181@redhat.com> <8d187891-f131-4912-82d8-13112125b210@redhat.com> From: David Hildenbrand Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qaSr0ID2sz5jtBLRb15RMre27E1ImpaIv2Jw8NJgW0k/D1RyKCwaTsgRdwuK Kx/Y91XuSBdz0uOyU/S8kM1+ag0wvsGlpBVxRR/xw/E8M7TEwuCZQArqqTCmkG6HGcXFT0V9 PXFNNgV5jXMQRwU0O/ztJIQqsE5LsUomE//bLwzj9IVsaQpKDqW6TAPjcdBDPLHvriq7kGjt WhVhdl0qEYB8lkBEU7V2Yb+SYhmhpDrti9Fq1EsmhiHSkxJcGREoMK/63r9WLZYI3+4W2rAc Uuc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Peu59Y5vSJOx/z6OUImD/GhX7Xvkt3kq Er5KTrJz3++B6SH9pum9PuoE/k+nntJkNMmQpR4MCBaV/J9gIOPGodDKnjdng+mXliF3Ptu6 3oxc2RCyGzTlxyMwuc2U5Q7KtUNTdDe8T0uE+9b8BLMVQDDfJjqY0VVqSUwImzTDLX9S4g/8 kC4HRcclk8hpyhY2jKGluZO0awwTIMgVEzmTyBphDg/Gx7dZU1Xf8HFuE+UZ5UDHDTnwgv7E th6RC9+WrhDNspZ9fJjKWRbveQgUFCpe1sa77LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 19 Oct 2023 08:42:10 -0700 (PDT) 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