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 33A6BE784A4 for ; Mon, 2 Oct 2023 08:00:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A12158D000E; Mon, 2 Oct 2023 04:00:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9C1AF8D0001; Mon, 2 Oct 2023 04:00:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 88AB88D000E; Mon, 2 Oct 2023 04:00:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 77A9D8D0001 for ; Mon, 2 Oct 2023 04:00:11 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 1A53FC015F for ; Mon, 2 Oct 2023 08:00:11 +0000 (UTC) X-FDA: 81299773422.02.5340E5C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf04.hostedemail.com (Postfix) with ESMTP id D125C40014 for ; Mon, 2 Oct 2023 08:00:08 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="dlkSa/MB"; spf=pass (imf04.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=1696233608; a=rsa-sha256; cv=none; b=JyxymUVp4sLr0WIphK6AQe8WQLw3NTqKb4hKkd3O4/yzKOst5Xe3Z473ygxHXI+AOaozoN EgPtpJKMBQyLezfseY3RjPeoHXDhTTXs2klv/LNKIi7ccTkuSiONngJbpx6LAllt77vcNt s8pJObmNixWCc+W/MBSGEczL690Jlsw= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="dlkSa/MB"; spf=pass (imf04.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=1696233608; 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=2hMwBDQxPqEr2KGnCZRjOsa4DbxGMCcRw1+qHGhTgF8=; b=K/c8O3P1vRvwautVRaeBlekLw4fDIwnA3WJg40Rwazk5+c71gge8AYqJXqYn3pL7NTJm/V 6EFnIS0FVt4kedZF9OatUyeYTIUElIOo5pATu8QIRPUuv5dmsnau1SYCYmJpCa9hK1qlOY cczyzuBML4GtfJY0CThmzGBKB4S28ds= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696233608; 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; bh=2hMwBDQxPqEr2KGnCZRjOsa4DbxGMCcRw1+qHGhTgF8=; b=dlkSa/MBKxMnCmVhC4xqTA85+AtEDORgMq5Z8lSyuaCZEaqeDXNDmbsVe33SdTvE7ohOEs fDP2eG/2kdW7mWUujW39ujQqfr1nQSZXW0wt7PjZjjIUGdTOZRjbwHl7pBjSl9iVzt18+B 8lOO1BDF3YLZ5cKeBw6vblOVsWwD0l0= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-581-jIdQDNIgMCeIemTxLKwy7g-1; Mon, 02 Oct 2023 04:00:06 -0400 X-MC-Unique: jIdQDNIgMCeIemTxLKwy7g-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-405535740d2so120332375e9.3 for ; Mon, 02 Oct 2023 01:00:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696233605; x=1696838405; h=content-transfer-encoding:in-reply-to:subject:organization:from :references:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2hMwBDQxPqEr2KGnCZRjOsa4DbxGMCcRw1+qHGhTgF8=; b=RoELdnDOTFCYp5tHG7QD8Bcx4cr13NavSyBsuX16dKb3IMDJfVuKuaMtoyKxeuEedc x178FYhOYOzh4goPM9Q4qVEoEEWSnqEhBb+eu7ONguCk1UdEDFvWT1/i6VO9dgFF7cuc 3AUDQ0dP5FjXM3DL4uW2dxs5EqcIICVopUJRwrcywL6NbsIZubaeaOxtoU0622aEkpAJ XVMGekn2E/QowBHI2lMtFWlr0QBcOYvtbqSFngsrCkQSWsLmaXn5zfJG/s9iwpszwThQ UtQFsWpUjr24P+a/YFzHvRMK8Tb3dnhdHuVVNtPy661/BSk1Fr7wdr1jdYhFTvDydJIN n7+Q== X-Gm-Message-State: AOJu0Yx4i+nLdFpeNrBeaxRij5xMydu5F6I8L95Lf9n5V2Aa3XilxIog hmnXbXIFp2nO5KNYNL6QyP2KQGTbEIFbQ22UoHU2SuUe3cfTn50xkSGmdVCJekwFA42AfWFgM6p uu4SB00uDygw= X-Received: by 2002:a05:600c:ac1:b0:402:f501:447c with SMTP id c1-20020a05600c0ac100b00402f501447cmr9457525wmr.0.1696233605519; Mon, 02 Oct 2023 01:00:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFLXTkL+9EEt3zHQk5ZsLeQprJDYGJsst31lbLdGGFpUez2Jqfmw0gPneDp6ON/b1DJjaaQzg== X-Received: by 2002:a05:600c:ac1:b0:402:f501:447c with SMTP id c1-20020a05600c0ac100b00402f501447cmr9457493wmr.0.1696233604995; Mon, 02 Oct 2023 01:00:04 -0700 (PDT) Received: from ?IPV6:2003:cb:c735:f200:cb49:cb8f:88fc:9446? (p200300cbc735f200cb49cb8f88fc9446.dip0.t-ipconnect.de. [2003:cb:c735:f200:cb49:cb8f:88fc:9446]) by smtp.gmail.com with ESMTPSA id 3-20020a05600c020300b004063cced50bsm6701171wmi.23.2023.10.02.01.00.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Oct 2023 01:00:04 -0700 (PDT) Message-ID: Date: Mon, 2 Oct 2023 10:00:03 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 To: Peter Xu Cc: Jann Horn , Suren Baghdasaryan , akpm@linux-foundation.org, viro@zeniv.linux.org.uk, brauner@kernel.org, shuah@kernel.org, aarcange@redhat.com, lokeshgidra@google.com, hughd@google.com, mhocko@suse.com, axelrasmussen@google.com, rppt@kernel.org, willy@infradead.org, Liam.Howlett@oracle.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: <20230923013148.1390521-1-surenb@google.com> <20230923013148.1390521-3-surenb@google.com> <03f95e90-82bd-6ee2-7c0d-d4dc5d3e15ee@redhat.com> <98b21e78-a90d-8b54-3659-e9b890be094f@redhat.com> <85e5390c-660c-ef9e-b415-00ee71bc5cbf@redhat.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH v2 2/3] userfaultfd: UFFDIO_REMAP uABI 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-Server: rspam08 X-Rspamd-Queue-Id: D125C40014 X-Stat-Signature: 4gbhnxuittyopddd58mpnus34jadp7kg X-Rspam-User: X-HE-Tag: 1696233608-845085 X-HE-Meta: U2FsdGVkX198rnik2aZh6hsSTso67nPu0UK4TUTG5ggUxZ+Cbu4lVSF7s6FnjsCr/DA+PKJKdKMzsEhdxrWkEjZ2aDo/HILFreLeolYBb91mtkq+rwzlqO3U76ouJZRbbMMrao0FaxU9X+eVukXYnYJbkJzd94CoMRmhORC/aCvq+2S8hKsI9SZlvXZHp2IcZOhCJAxTdxan+AEaKN36+MDJOutVAyNBRoZH0xg4w9p322vhn4jrQvjO9WjuVsZJYr9/Q0o7sfajtJEoR0zpd/+TYfPfXdRadOiSDQwDGkt1pUsF7yIfqbphqHyaRkZUZ8bST3GJ//Txq7RNc/H0NMgfSjR8aLRYg87/dhqo3DP3HY1zoWqZAMh0i+hfX2m3MfdzCAcrGGxxxYJqNoAP/uIgMOoshOTRGmmpOND8loqCa7lT6JT++1C0h2N8S5uOT5QaDJ7r+MkTlaOZ4E3rETfhm8dfb1+/TgwGnOFnBTCZoe86/BwAt/3vKxwmzcANyHy8yDOgoVrLz/9ZE0EWdSfK9pP3NuF1VWf/nJNfgakROWpp9kk3K8BV4K+iQWnG+4/7e2e1zAEIAvWeN75omo7w9rzIFqGsrzHULniqYCvP99l695p3n5b/FBBGMtUKBnpL/BVFj3pKe4sGsXV1IWgg+4RS9+zNiU7qyWovmRJEYj97h2xn00hu/JXaJlihvSqYWqgc10+X35zbZaXiFCd9OOHcsvVPJkdAytfFa+OVbbUpUmJnfzsAa6TrRzW6LkfhKmh4prpU3UxuCRFZ8XJM7NDrW6gBgqZ3zI4hLf96scfqvSz9tTabsGGDCjR4Dn4yX49Hf9ug2oglByZqx0spgDUtBvkr776rFk7/aefWfeW54CywiUQ8Sb4byXeMXiMvX1fToAejwJDtRd34VI2aMfqljHDlPTX7j2/eAecm05REfIincAW5RgXVAw2Im1GcuDfBw+olAbtGO9E ZbaiL/xK qWhfwbWPQ52PQ8fqbqTfuLinnrbAHZpIGwK6kkbjruJ16kSc8/t7+vCQtdF8lizgcZm0KrtOJlDGfutEYpOkV8Nk57wHqw0h1S1Sn7Z8RLCt/XyP4uJgT7pPoL4m7ToVMtfDDo2yS91rCRsGA7YlBdMdiqYDt+btbhRfmxsjJXiq5V5EYlKKG3EmjrI2WK8lTn+ZNgc16N41pAQ/CYpU/EyYE3ZKNHKiwvvldNQ+j5XbI5rze824MGXIxd2L3e4oZ7WR8XcEPwB6b2vJyn6FtoRY9dlijRrym7piqRMm70YNuol7nEMHlXFbxAatGaZf3mFNvjofup9POodRw99fCVLGcWej8wzbG1MzeIuyVnlKjWjpMsUztqpqiMDqaK38T7d/9fAVu9aKOc3mLS8m2PQpFnGASbFG/ohndvC/AompTgo79gyZIZZ523g== 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 28.09.23 20:34, Peter Xu wrote: > On Thu, Sep 28, 2023 at 07:51:18PM +0200, David Hildenbrand wrote: >> On 28.09.23 19:21, Peter Xu wrote: >>> On Thu, Sep 28, 2023 at 07:05:40PM +0200, David Hildenbrand wrote: >>>> As described as reply to v1, without fork() and KSM, the PAE bit should >>>> stick around. If that's not the case, we should investigate why. >>>> >>>> If we ever support the post-fork case (which the comment above remap_pages() >>>> excludes) we'll need good motivation why we'd want to make this >>>> overly-complicated feature even more complicated. >>> >>> The problem is DONTFORK is only a suggestion, but not yet restricted. If >>> someone reaches on top of some !PAE page on src it'll never gonna proceed >>> and keep failing, iiuc. >> >> Yes. It won't work if you fork() and not use DONTFORK on the src VMA. We >> should document that as a limitation. >> >> For example, you could return an error to the user that can just call >> UFFDIO_COPY. (or to the UFFDIO_COPY from inside uffd code, but that's >> probably ugly as well). > > We could indeed provide some special errno perhaps upon the PAE check, then > document it explicitly in the man page and suggest resolutions (like > DONTFORK) when user hit it. > Maybe it might be reasonable to consider an operation that moves the page, even if it might do an internal copy. UFFDIO_MOVE might be a better name for something like that. In case we cannot simply remap the page, the fallback sequence (from the cover letter) would be triggered. 1) UFFDIO_COPY 2) MADV_DONTNEED So we would just handle the operation internally without a fallback. The recommendation to the user to make the overall operation as fast as possible would be to not use KSM, to avoid fork(), or to use MADV_DONTFORK when fork() must be used. -- Cheers, David / dhildenb