Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3355915rdg; Tue, 17 Oct 2023 12:01:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEF+ALc/kWONGixq9Juun+2JoVhMPJ0MJvCrbvUJy/CnxIF1Xy0YEEAQ6IroS7gVyGaq7Xd X-Received: by 2002:a05:6a20:938b:b0:151:35ad:f327 with SMTP id x11-20020a056a20938b00b0015135adf327mr3670604pzh.17.1697569273329; Tue, 17 Oct 2023 12:01:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697569273; cv=none; d=google.com; s=arc-20160816; b=sY6RaM1Ur5RralYiG3cYUIIdbY+pY+uE+EKR4vW9WkPBEVqaOK79HvMPq+KEVo2S/C WpEVMwJRAVRBNXC6HHwxaczDeo17gQfop8sAaawjc5juDra3GcxjoBZnNDBD/XN0XU/T UesMkMVUgbkk9qyDBeICs3XaHHGtMFhfelsJflcUkGm27BEYOlJUZBb0/teXbbaW2hnU xAyBVDbPFXDolVX3Two1WP9BdoIkPLEkkKVjlUT7cj7MyCB1svB80L5+bIEh4I3ZWMS9 IA44E2AL7jvgyVKz9JZbqXEKZDdY5SWSo7AZLLB/RIsvALmRpRVuW/6S1Hm6ngBgHz/z AJYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ufWNltmtm9MEQJk/HA+zcNGOIx26ETEdVffppRZYG34=; fh=iiu5FdpUSgnzzd9m08fY+7QmpnpRxSEb+iQIEhNGdWg=; b=HtoYVD4fKUWKi2fzJmp227an/14lNVp1DKnN1OYTStLM/fmNdtQRzLKaum5jkRMZms OvlBbzSWQQemrk2Kd35prHPjjDmINy5vWkYCB9f91+I8coYMVFfbuWxMaXlhVGlqlr+F WODQktqsI/qxEbZcQ4WXdVX2xRoMnkeNgop+RnCJ57eSVlSymXi7ZuVKu+HU/svDHrht 8FGhxsTNUQyrrB+dmz63Ay5PY1E1EFLtWu6sFs2unXf8U1/SZrm+hy4z+xSk2Eb+IW4j Bwa36pwhvsR0J8214rDKratkoHIaVamwZNdBGpLgK29L7jXEI3ZtXZH6cEQPJNZMtRpI H6gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZNFiIhv6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id mu17-20020a17090b389100b00267ba1c43adsi2460499pjb.101.2023.10.17.12.01.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 12:01:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZNFiIhv6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id E3A3B802D470; Tue, 17 Oct 2023 12:01:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235031AbjJQTBB (ORCPT + 99 others); Tue, 17 Oct 2023 15:01:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234982AbjJQTA6 (ORCPT ); Tue, 17 Oct 2023 15:00:58 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB625107 for ; Tue, 17 Oct 2023 12:00:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697569206; 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: in-reply-to:in-reply-to:references:references; bh=ufWNltmtm9MEQJk/HA+zcNGOIx26ETEdVffppRZYG34=; b=ZNFiIhv63uLXGoJHbKyFepZ4GTxC2Wa+gzeoJHtlr4HbYI9960r4NSNj2hUswsiDqKl0I0 wH7lzfoV4ZjK++w+JAoukeNM2wsGEcybCazh5xdV/o9mfgk8awp++kc1Nx5/i74G1XndGq 9KSfdKqg8XfxSHbgos5OZaIL8KtAJSI= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-339-yG-FnpV1OJen6abBCyVahw-1; Tue, 17 Oct 2023 14:59:59 -0400 X-MC-Unique: yG-FnpV1OJen6abBCyVahw-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-66cfa898cfeso11918436d6.0 for ; Tue, 17 Oct 2023 11:59:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697569199; x=1698173999; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ufWNltmtm9MEQJk/HA+zcNGOIx26ETEdVffppRZYG34=; b=vxkzgqkZYad0AYsFqhgWnK0/l0t+Z5H+U2elBryHuK1oTA23VA5KVw5VB+z2Bj0/e/ WxAE9ra0Q7GH+uLSb01lDQOBH73BI9B/pnGKlAwyAnn+4bCi+ZAaQhbKMWUVi5QTEdDw 9kKaArZVaUeLnD/scwzUWSIde/QCioDGjo5KKZsgjzZS0falj72ZxRFbK5OoVnLIk+/I hccgHP45aaPxdn6o4VJFrm3FcxfiZvLwVZa67iE2CazfNsBG06rbT1N3F8Co2ZIZa70l DUVIwlsTjtYuFxqylSzJRqtIO8M7na+zzSjoDg8Dke8JIKacz8kDirCXzoTIBx8IY4GB FU4w== X-Gm-Message-State: AOJu0YxGR8URUv1OBrsno8Lbz84qNsf9QQWqQUUOl8YDAiR2MSlUbQj3 qoe32Vkt9Fb6HiCQJqD86hdZTLT0Gh4akjzVcQou0wW9XGQA/AJf2Ge5MzkwvZkW7L4x5M8biYg T7+NlKghV0SXOKt2c2HDuruBn X-Received: by 2002:a05:6214:5b04:b0:668:e12a:1d1c with SMTP id ma4-20020a0562145b0400b00668e12a1d1cmr3335085qvb.3.1697569198757; Tue, 17 Oct 2023 11:59:58 -0700 (PDT) X-Received: by 2002:a05:6214:5b04:b0:668:e12a:1d1c with SMTP id ma4-20020a0562145b0400b00668e12a1d1cmr3335060qvb.3.1697569198391; Tue, 17 Oct 2023 11:59:58 -0700 (PDT) Received: from x1n (cpe5c7695f3aee0-cm5c7695f3aede.cpe.net.cable.rogers.com. [99.254.144.39]) by smtp.gmail.com with ESMTPSA id pz2-20020ad45502000000b00655e428604esm768163qvb.137.2023.10.17.11.59.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 11:59:58 -0700 (PDT) Date: Tue, 17 Oct 2023 14:59:55 -0400 From: Peter Xu To: David Hildenbrand 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 Subject: Re: [PATCH v3 2/3] userfaultfd: UFFDIO_MOVE uABI Message-ID: 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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <8d187891-f131-4912-82d8-13112125b210@redhat.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email 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 (howler.vger.email [0.0.0.0]); Tue, 17 Oct 2023 12:01:09 -0700 (PDT) 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. 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? [...] > 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). 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. 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. [...] > 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? 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. Thanks, -- Peter Xu