From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA1B6CDB482 for ; Tue, 17 Oct 2023 15:55:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 54FDA6B0287; Tue, 17 Oct 2023 11:55:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5017C6B0288; Tue, 17 Oct 2023 11:55:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 326DB6B0289; Tue, 17 Oct 2023 11:55:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 1EB506B0287 for ; Tue, 17 Oct 2023 11:55:20 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id D96DB80CFF for ; Tue, 17 Oct 2023 15:55:19 +0000 (UTC) X-FDA: 81355402758.20.15C5E72 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf27.hostedemail.com (Postfix) with ESMTP id 669834001E for ; Tue, 17 Oct 2023 15:55:17 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=gzV4Dsv0; spf=pass (imf27.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697558117; h=from:from:sender: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:dkim-signature; bh=lczccd5vGYHNveSJtrvYvza5KZbdNK74xDRFaP3BLsU=; b=pCHGvSEKs2+SuAXn1YjGS0HL3x6jcd3f0fd9L4khArL2GMR9ezhKtGK7O2zfMaAlF4vtoh pD9jv0nmAoUGcDhpgTEg9zuIqyKrMDm36ltWZGdzceiYoewqmB1TXngqJwz2Zehs/zq4Dx z6bimsIk10DBogjBL37Dr0S7SobSSFo= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=gzV4Dsv0; spf=pass (imf27.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697558117; a=rsa-sha256; cv=none; b=2r7BoDplh15DcPP06qxf0Ej9pHDW1/+36vF+bUvrw7TjFB1c8zjFozHyJpsZFAvGAEMr0x gQZ+0b5gFAqTB95J4s/CWUFlj1yEAxpLJ9EtsJDbNWv4/t0Ww2n6ZqCVLZ6jsfOOncQJgW SkFb8zcvQpGTIfgN55W0wMYNF+YZzNU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697558116; 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=lczccd5vGYHNveSJtrvYvza5KZbdNK74xDRFaP3BLsU=; b=gzV4Dsv0dWqYC0ap5wi2JpM9M6NWRyhowiA0BHbYSfnBtHZKBXwNYSJprnNsu/okCnMhpr k+LjDxRuWTgdVApLTWY5SrHAAGkz7LaAbrrk+oXtw/u8/fx9eamJLQPXkw6eLAGGNORyCe 14QDcX/jiZgeoiDe4amb6vOOvSqzgj4= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-573-SGBmXvChMSew34WqAFlZmg-1; Tue, 17 Oct 2023 11:55:14 -0400 X-MC-Unique: SGBmXvChMSew34WqAFlZmg-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-32d931872cbso3275605f8f.0 for ; Tue, 17 Oct 2023 08:55:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697558113; x=1698162913; 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=lczccd5vGYHNveSJtrvYvza5KZbdNK74xDRFaP3BLsU=; b=aLtc/dYTveANRvKaInjZpTs6oJZIJIgRnEpG57UFvDx/iEW01du0prGcFFM06xY2GU kh6TcSnOzPWejzSvogU8jv0VCN3rop2cjt9AVrUbng9d4G54VX2ax768vCKfxmwQi7/n tYmtxLs/rA9hwLthV0ydiRn1LOTKvEocH1I+jgmx/Wf4lWJPm/tf0mtcJKEyAL7cno4h OoSxhgXVF1lfxVIw28OX9amiLEA7vrfD1blt1cIbtRoePOyIDcvt9jDBuTFJMq8IIJnQ g6riq5MoaWJDV6yc1AI4dp81WlrmE4sMO9hMaK8s8wHeCZ+HV1xtlurNoUg3E6QpTDwQ o64g== X-Gm-Message-State: AOJu0YzNwJn33VCV3Ntp1rzL4LOxDEpTczwsrm7hmxn/ZVvyxLdBNvQW 9Wk9i2TxgeL8BJz8r4NZEN3xd8IIKwi8FKPjL/yWJUqtTU1axYjJg2PLh6/x4U4MmCktWHKjI1y BM4FwsVABFnk= X-Received: by 2002:a5d:4e90:0:b0:32d:a4c4:f700 with SMTP id e16-20020a5d4e90000000b0032da4c4f700mr2378802wru.38.1697558113288; Tue, 17 Oct 2023 08:55:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFMTNi5yp+q9KhRwbZFlporOHnmTNt0F08bdCSYm6ry3kyMwqIR+9TO7W83KbpsF+QxwPkXeA== X-Received: by 2002:a5d:4e90:0:b0:32d:a4c4:f700 with SMTP id e16-20020a5d4e90000000b0032da4c4f700mr2378780wru.38.1697558112865; Tue, 17 Oct 2023 08:55:12 -0700 (PDT) Received: from ?IPV6:2003:cb:c743:5100:93b1:f654:ad11:cd81? (p200300cbc743510093b1f654ad11cd81.dip0.t-ipconnect.de. [2003:cb:c743:5100:93b1:f654:ad11:cd81]) by smtp.gmail.com with ESMTPSA id b17-20020a05600010d100b003197869bcd7sm65944wrx.13.2023.10.17.08.55.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 17 Oct 2023 08:55:12 -0700 (PDT) Message-ID: <8d187891-f131-4912-82d8-13112125b210@redhat.com> Date: Tue, 17 Oct 2023 17:55:10 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 2/3] userfaultfd: UFFDIO_MOVE uABI 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: <20231009064230.2952396-1-surenb@google.com> <20231009064230.2952396-3-surenb@google.com> <214b78ed-3842-5ba1-fa9c-9fa719fca129@redhat.com> <478697aa-f55c-375a-6888-3abb343c6d9d@redhat.com> <205abf01-9699-ff1c-3e4e-621913ada64e@redhat.com> <12588295-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IuCL4YjVoylWiBNknvQWBXS lQCWmavOT9sttGQXdPCC5ynI+1ymZC1ORZKANLnRAb0NH/UCzcsstw2TAkFnMEbo9Zu9w7Kv AxBQXWeXhJI9XQssfrf4Gusdqx8nPEpfOqCtbbwJMATbHyqLt7/oz/5deGuwxgb65pWIzufa N7eop7uh+6bezi+rugUI+w6DABEBAAHCwXwEGAEIACYCGwwWIQQb2cqtc1xMOkYN/MpN3hD3 AP+DWgUCXw7HsgUJEqkpoQAKCRBN3hD3AP+DWrrpD/4qS3dyVRxDcDHIlmguXjC1Q5tZTwNB boaBTPHSy/Nksu0eY7x6HfQJ3xajVH32Ms6t1trDQmPx2iP5+7iDsb7OKAb5eOS8h+BEBDeq 3ecsQDv0fFJOA9ag5O3LLNk+3x3q7e0uo06XMaY7UHS341ozXUUI7wC7iKfoUTv03iO9El5f XpNMx/YrIMduZ2+nd9Di7o5+KIwlb2mAB9sTNHdMrXesX8eBL6T9b+MZJk+mZuPxKNVfEQMQ a5SxUEADIPQTPNvBewdeI80yeOCrN+Zzwy/Mrx9EPeu59Y5vSJOx/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: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 669834001E X-Rspam-User: X-Stat-Signature: jjqkkit5cz1nyy6mhk1reg1m5uqj6c57 X-Rspamd-Server: rspam01 X-HE-Tag: 1697558117-190446 X-HE-Meta: U2FsdGVkX199tb2AhRl1HlJR/Nz1UJyE6jXThTSyHRaMpRZqLivSdwhBhXmsmwJP33xC+AD65jBWt2Jayfz68d9rJW578YlS6ERI1mO5LyMWliifCETSZ2L6fjRRbTs5NbGFKfRAbprSbL568B1gvZEvPFi2arHuKKuswUO0wy2g34pU0NTsgCZ+jGAlA9e1XAO6Ce0PQCDDvQek30K+oKUaQAskgnGPFTt3ryvV8Eob60la3a/B2j7UWUnw00RaJCLN/EgqAq4/c4TLeI26dKWN7y7NxGD7DO6ivVwopCL61mA1uAfq0sAPXti+ITMlfd028Gb4b3sBIR70RfjqIdVIgP2kFL0OSF+UPio4cB1/O1WNQBZkrMy25U6TK+DLNvYi5JnT/da9ZgGXRkkyWsewQ6hYEIPpAAWKDRLBCp9GzpW8h5qHTw+VVizhWHqoZiRTx5N/PKg+XGom2MNgrypUxlrNnGo+O/iU+UCkjKVZEg63D5uAZhyR7hBtv+a5wG8PfIBCXWIz1t5bea05Ef3usNrGvea594HNW60agbaA5niHKZkvUQXXoiu3pmpsHd61f0yUk66KbHdIjQMhTTxL7UawvLouUJhJd52EChhoJz+fGJpsEkfAtYGCKKQWuu0zihGaCCA3Mjx6H2IWJ4zFQXsEgOk034eoOfaGwY3BUcMUSLigS0rOMlRvVSeAqeIb0mllRRnxMxdvPobIZq2LcYwaBXCmPezPuxOD0bPTYUnacP3PZJ/97QfdgbrstIM4HgbZ4L4+a6vusQtfT/M0sCa6bCkcwPjam7hHcbzowlP0Z07WggzNtfZ+8s+ozjp020hOWlKECREm6KEkp6HjtjbMG2QpddrAb/3dlGgxfhSaa632jjSCgIHq/5PE5g/CzpMW/nwvFr9DaEt3mBPXX5tm4RIAlWyjrbG06KoRj4fT7tnCXIH5SNMp/BDkp6aMa2M3DoMLqnwXpjn 5HMktkFf sY4S9n1iWNrFSN7qYjYJqvRko2/dmjCyaZ9X/TZBcVUm2nIwYTwjCwJhC145DgNyipklBWSCsyBXeO9IDgN7tCDETmZXnba+A2MXDvPBDdrcploU51D3K04loB+/JPGQRtqdG0AwmPkTUaC2OJGx2V/2Tx+oig7WX2lUpmnQmYfuh46X6E5gjLiYjq1B3XKr4l2W2RAbxPVbzKp1KypxicqNedjw7tu8qZ1E0QOAl3GRuTg2vsfbb6T6eegVDCTbkYEPhUZXDBqBZVTNGe0gP1zV23tj8euQ9oZKkRAy9t18uI7TxZeMyA6Oi2DXBWBV3zdi58aCOgGd1b7F07419ZUnk6VCIvLzClndwsM9nl5L5/1hhSWkZp4HhpZlaw3XSsbmXmAD5IjNGKrUrSwuQO4gtwRGotFQpB6dXZva8nC4EHyIouGEOYl8AyoXcWNhbUpIXHeOyZfmWwmrvvNO4g/u5TA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 16.10.23 21:01, Peter Xu wrote: > David, Hi Peter, >>> Basically I see it a potential way of moving memory efficiently especially >>> with thp. >> >> It's an interesting use case indeed. The questions would be if this is (a) a >> use case we want to support; (b) why we need to make that decision now and >> add that feature. > > I would like to support that if nothing stops it from happening, but that's > what we're discussing though.. > > For (b), I wanted to avoid UFFD_FEATURE_MOVE_CROSS_MM feature flag just for > this, if they're already so close, not to mention current code already > contains cross-mm support. Yeah, but that implementation is apparently not sufficiently correct yet. 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. > > If to support that live upgrade use case, I'd probably need to rework tlb > flushing too to do the batching (actually tlb flush is not even needed for > upgrade scenario..). I'm not sure whether Lokesh's use case would move > large chunks, it'll be perfect if Suren did it altogether. But that one is > much easier if transparent to userapps. Cross-mm is not transparent and > need another feature knob, which I want to avoid if possible. And for me it's the other way around: the kernel doesn't have to support each and every use case. So we better think twice before we do something we can no longer undo easily. Further, as we see, this feature without cross-mm capabilities is perfectly usable for other use cases. So even limited initialy support is extremely valuable on its own. > >> >> One question is if this kind of "moving memory between processes" really >> should be done, because intuitively SHMEM smells like the right thing to use >> here (two processes wanting to access the same memory). > > That's the whole point, IMHO, where shmem cannot be used. As you said, on > when someone cannot use file memory for some reason like ksm. Right, but as I explore below KSM will at least prohibit remapping the KSM pages, taking some of the benefit away again. > >> >> The downsides of shmem are lack of the shared zeropage and KSM. The shared >> zeropage is usually less of a concern for VMs, but KSM is. However, KSM will >> also disallow moving pages here. But all non-deduplicated ones could be >> moved. >> >> [I wondered whether moving KSM pages (rmap items) could be done; probably in >> some limited form with some more added complexity] > > Yeah we can leave that complexity for later when really needed. Here > cross-mm support, OTOH, isn't making it so complicated, IMHO. > > Btw, we don't even necessarily need to be able to migrate KSM pages for a > VM live upgrade use case: we can unmerge the pages, upgrade, and wait for > KSM to scan & merge again on the new binary / mmap. Userspace can have > that control easily, afaiu, via existing madvise(). MADV_POPULATE_WRITE would do, yes. 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(). [...] >> >> single-mm should at least not cause harm, but the semantics are >> questionable. cross-mm could, especially with malicious user space that >> wants to find ways of harming the kernel. > > For kernel, I think we're discussing to see whether it's safe to do so from > kernel pov, e.g., whether to exclude pinned pages is part of that. > > For the user app, the dest process has provided the uffd descriptor on its > own willingness, or be a child of the UFFDIO_MOVE issuer when used with > EVENT_FORK, I assume that's already some form of safety check because it > cannot be any process, but ones that are proactively in close cooperative > with the issuer process. 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. > >> >> I'll note that mremap with pinned pages works. > > But that's not "by design", am I right? IOW, do we have any real pin user > that rely on mremap() allowing pages to be moved? If in doubt, usually "probably yes". Hard to tell if the "remap" in mremap indicates that we are simply remapping pages , and not moving data. > > I don't see any word guarantee at least from man page that mremap() will > make sure the PFN won't change after the movement.. even though it seems to > be what happening now. If you managed to support page pinning with migration the exact PFN doesn't matter. Likely nobody would implement that due to the tracking complexity. > > Neither do I think when designing MMF_HAS_PINNED we kept that in mind that > it won't be affected by someone mremap() pinned pages and we want to keep > it working.. > > All of it just seems to be an accident.. Not necessarily my opinion, but doesn't really matter here. It's working. At least It's reasonable to have part of a THP pinned and mremapping the other part of the THP. That makes things more tricky ... because you only know that the THP is pinned. > > One step back, we're free to define UFFDIO_MOVE anyway, and we don't > necessarily need to always follow mremap(). E.g., mremap() also supports > ksm pages, but IIUC we already decide to not support that for now on > UFFDIO_MOVE. UFFDIO_MOVE seems all fine to make it clear on failing at > pinned pages from the 1st day if that satisfies our goals, too. Yes. -- Cheers, David / dhildenb