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 X-Spam-Level: X-Spam-Status: No, score=-24.8 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BB8CC43462 for ; Tue, 27 Apr 2021 02:20:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 07732610FA for ; Tue, 27 Apr 2021 02:20:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231450AbhD0CUq (ORCPT ); Mon, 26 Apr 2021 22:20:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232295AbhD0CUp (ORCPT ); Mon, 26 Apr 2021 22:20:45 -0400 Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB9EEC061760 for ; Mon, 26 Apr 2021 19:20:02 -0700 (PDT) Received: by mail-qt1-x833.google.com with SMTP id l1so3404585qtr.12 for ; Mon, 26 Apr 2021 19:20:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=Pnjy0987JUk+XLq8j9TrVexd3W3Gw7OXJFli75KyJ+4=; b=u64LXe7Cb+0e8JDoca4bg7GXvns1jVhNN/1lrHEK6AA0rHZtcLkcX3be1h7jskVl31 fE25+77GZ9g/Dc4UE0PHM6PbWpyK94nJXiHFVI2S9vzugysoYgwhzfIbV0AqEOEQcd0u 4+TlPstRSAiJQsm55Z6xOyzKXlcAFoB+1oztR/mueVwrjc0Oapr5vAmogWbYlqxSEqZU TO+bOlio/PqbIqWfzTi3jGzHbVkEpvdfVj+Khpyuk9J5Vl8o+xolrF3N3mQRdqfjhQe4 wJvTUoTHPmjWaYTgeqHslGJuIT9SVI/R24WrDMy5psIDPMJ7Y6QncSSQKmkKOEn9ye9w wPcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=Pnjy0987JUk+XLq8j9TrVexd3W3Gw7OXJFli75KyJ+4=; b=FhTkFrhToE8V9xyVdfegUE1kUtP06kTRLWr0Y2MQpnktNFzJS8ioKvyvEGRfXDL5rv m3sYHhcIDs+r2M5tnig02JQXmG5qWIHcS09uMBVYzwaVZfS3vTCasju+YoqFLC+5jE++ UukWDBVJLIb2oYU3Wnn6VRAnE3YaLadoRIi5RA59HuUZXXhxbXgxIhBXchvnvjoMFccK vZois71LGPbnGI6b26ApGbRh/5xU5d0roFhTTS16MYd2Vnl4mdQngo4l7wH8G/Nl/dPX kQ8Oy5Q9F+tgOkgBrffCai7pGPLB4CE0MqCkFLPfhR7Sx2etFqwS1jm6cRgol3AvWvQK uhrQ== X-Gm-Message-State: AOAM530HWejrvVmGv2x4wShrVG7VKDUs0Yccl3QpBhH13eEv+6/OHXLy lBYfJSIsY70S1n8ZSZ/v6MIxaw== X-Google-Smtp-Source: ABdhPJxyAyKDzzCT+LoVorKFwJsNfqzw1n6Udw1ypZ16lcbMZ2s8WnBbaReftHIWcDVX8txvy6ZvyQ== X-Received: by 2002:a05:622a:245:: with SMTP id c5mr10322745qtx.350.1619490001558; Mon, 26 Apr 2021 19:20:01 -0700 (PDT) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id 185sm1855770qko.99.2021.04.26.19.19.59 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Mon, 26 Apr 2021 19:20:01 -0700 (PDT) Date: Mon, 26 Apr 2021 19:19:58 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Axel Rasmussen cc: Alexander Viro , Andrea Arcangeli , Andrew Morton , Hugh Dickins , Jerome Glisse , Joe Perches , Lokesh Gidra , Mike Kravetz , Mike Rapoport , Peter Xu , Shaohua Li , Shuah Khan , Stephen Rothwell , Wang Qing , linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, Brian Geffon , "Dr . David Alan Gilbert" , Mina Almasry , Oliver Upton Subject: Re: [PATCH v4 03/10] userfaultfd/shmem: support UFFDIO_CONTINUE for shmem In-Reply-To: <20210420220804.486803-4-axelrasmussen@google.com> Message-ID: References: <20210420220804.486803-1-axelrasmussen@google.com> <20210420220804.486803-4-axelrasmussen@google.com> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-api@vger.kernel.org On Tue, 20 Apr 2021, Axel Rasmussen wrote: > With this change, userspace can resolve a minor fault within a > shmem-backed area with a UFFDIO_CONTINUE ioctl. The semantics for this > match those for hugetlbfs - we look up the existing page in the page > cache, and install a PTE for it. > > This commit introduces a new helper: mcopy_atomic_install_pte. > > Why handle UFFDIO_CONTINUE for shmem in mm/userfaultfd.c, instead of in > shmem.c? The existing userfault implementation only relies on shmem.c > for VM_SHARED VMAs. However, minor fault handling / CONTINUE work just > fine for !VM_SHARED VMAs as well. We'd prefer to handle CONTINUE for > shmem in one place, regardless of shared/private (to reduce code > duplication). > > Why add a new mcopy_atomic_install_pte helper? A problem we have with > continue is that shmem_mcopy_atomic_pte() and mcopy_atomic_pte() are > *close* to what we want, but not exactly. We do want to setup the PTEs > in a CONTINUE operation, but we don't want to e.g. allocate a new page, > charge it (e.g. to the shmem inode), manipulate various flags, etc. Also > we have the problem stated above: shmem_mcopy_atomic_pte() and > mcopy_atomic_pte() both handle one-half of the problem (shared / > private) continue cares about. So, introduce mcontinue_atomic_pte(), to > handle all of the shmem continue cases. Introduce the helper so it > doesn't duplicate code with mcopy_atomic_pte(). > > In a future commit, shmem_mcopy_atomic_pte() will also be modified to > use this new helper. However, since this is a bigger refactor, it seems > most clear to do it as a separate change. > > Signed-off-by: Axel Rasmussen If this "03/10" had been numbered 04/10, I would have said Acked-by: Hugh Dickins But I find this new ordering incomprehensible - I'm surprised that it even builds this way around (if it does): this patch is so much about what has been enabled in "04/10" (references to UFFDIO_CONTINUE shmem VMAs etc). Does Peter still think this way round is better? If he does, then we shall have to compromise by asking you just to squash the two together. > --- > mm/userfaultfd.c | 172 ++++++++++++++++++++++++++++++++++------------- > 1 file changed, 127 insertions(+), 45 deletions(-)