Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1500285rdb; Mon, 2 Oct 2023 11:23:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGhTD/g4wx45jyYDlDrYS/8Y9LvwFLUBS+pYzjTCNJ8ynqLGyy3GODFYICPLFi6112RUIFF X-Received: by 2002:a05:6a21:6da1:b0:15d:721e:44d5 with SMTP id wl33-20020a056a216da100b0015d721e44d5mr13311645pzb.49.1696270992331; Mon, 02 Oct 2023 11:23:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696270992; cv=none; d=google.com; s=arc-20160816; b=WRtih5On8E5wx+zkQ+NTsWWGRPx8sQgc865Kx3Vn374op4F4CLaWtwmeBW3e9aMruu lthy7sgrT8+++3v2rJxUv94LBvly22gt9MOfHRhK+it3CDnbjkiiGRvlNgfcqtyIZZBC 9mx8xEktaWPr/Oc3J3mrmy1jABvcWn24tD9Ptn4Mb94doOoTArMrhUvJF5Jzrggzn1wt Ef4JCkct77StMkxNHOfwX2hAyKZG0qTaONHV5REOBBLBRRj0N0URLdiRcDxsjXZz2dxQ MQqy/X8gk0JBghzbutiJdXBNldDtEmMKXWlLi791y75tfQ9V0tAg6+MxGFE90uh6w3ca 4oGg== 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:subject :organization:from:references:cc:to:content-language:user-agent :mime-version:date:message-id:dkim-signature; bh=2hMwBDQxPqEr2KGnCZRjOsa4DbxGMCcRw1+qHGhTgF8=; fh=MDU24jSgRWQwNFl40U2PL4F4FDBGL7b/QeWQPYWwNyo=; b=xIUkpUXV67xYsQpZpMxaBQf36TjyfMSdCOxeDS0Q0UF5IbrN7iLPWsmups+926Mi4X BC3YypfMEnU8esBYykmIV2Ldp7JllomOckAornemAFVlz6LUwxZcmZ2zTRi1S5YcnrZY RPRyv7h2dq0ac2iDYmgVELJir8kL6lnG1RJK1jFtThWOrRVK7DtYi/LzyiDCSfMqLSGD lz5r2/DVeLmw0tyryhkJO84RBONpe1BaJRNW8hhDCoYUYzqtDIdxp6rFZAjjY36vSW/O soiFqX3+/i1w2HQizsW8rsf4Ka5uummKxC6H6XmP9YULeICjnXnbngU071o4j1Oggin6 0piw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PuaY8BvU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id y184-20020a638ac1000000b00565660b78d3si26849342pgd.591.2023.10.02.11.23.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 11:23:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PuaY8BvU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 94B0780ACCFB; Mon, 2 Oct 2023 01:01:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235802AbjJBIA7 (ORCPT + 99 others); Mon, 2 Oct 2023 04:00:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229712AbjJBIA6 (ORCPT ); Mon, 2 Oct 2023 04:00:58 -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 5DAD5C4 for ; Mon, 2 Oct 2023 01:00:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696233609; 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=PuaY8BvUbZnHIXTBkBpArOROtKepAC9DHeW6wsABpNNQxvJmhlgrbNWXGQHv9K6F9tg3hz yRG3IjZ6L6nWxp2F0P7qA4S8BjtW9T122ArC892xrMLR9j1jbDa0ZCAZAbt3stD96zZKSP U64YovOWZUK9c8Vb0sHfqVTlYneqZk4= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-64-ftlcronVM4iC8m0QWImP2w-1; Mon, 02 Oct 2023 04:00:06 -0400 X-MC-Unique: ftlcronVM4iC8m0QWImP2w-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4065478afd3so25129375e9.0 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=Y2JPIoD3IWhwa7xa3EdbIFGWQOqO/6vyRFvH80wQbO0tyxett4NwvqHD+mJ2AUf8MW U/PPULdzvGLv05to0D0Kxnj0bOzluFQVETnuntOavdBcKVKnaAWuP5rZAUU8YrqSeQ92 w6wsIe4+Ktfe/5XorWACz3I6S533rXTiBOoNgv4oyhLGmY8CMNSupz1Rjo5gCQsLsoQt ldcXEy3lrzpVPSqbI79tfbXaryrX0liwsiANrf787WxuEzxNPDxFuJfurtn1zrev1UpH XWERGhZh9gG7Hrm1pO7Ug/Btb/WoHXOIOKITuOQcvbv7z85KrHXydhFFwhRwZj8K620f V8TQ== X-Gm-Message-State: AOJu0YxyRiQ6Jt5OCArLBCGeoD821rzBzZXars8a0BN+UqjabfGOrzzh Ms6egoi6KawLU51t7S5+G0Zk0Kg/QbAxmg4sbP/vBxiqnyOT+98GvxL0OIp5x3ZixWcpm8Zm2nq P2rOWTIK1y8YbLolAKTZd2Tow X-Received: by 2002:a05:600c:ac1:b0:402:f501:447c with SMTP id c1-20020a05600c0ac100b00402f501447cmr9457515wmr.0.1696233605511; Mon, 02 Oct 2023 01:00:05 -0700 (PDT) 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 Content-Language: en-US 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: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,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 agentk.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 (agentk.vger.email [0.0.0.0]); Mon, 02 Oct 2023 01:01:17 -0700 (PDT) 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