Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp4127495pxy; Mon, 26 Apr 2021 19:23:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDnuOO9QeE1Ja3C+eWOEBD2B3tmnl8tn4EXZOH83T2IUv69z+LOKXQXd1LcL9ZxK3953u8 X-Received: by 2002:a17:906:6683:: with SMTP id z3mr21622698ejo.390.1619490205652; Mon, 26 Apr 2021 19:23:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619490205; cv=none; d=google.com; s=arc-20160816; b=N9AOQupANY1jkD4TaDxfwkSrjMGohUXDEOhMvtnIGz8iC3emW+TIQEn5oN3IiItIVG HqTDSwOSCs1PpZB40KWIIs6QFlA0TCdjqfuaPaYpnHT1rq0ReMvI/mtfiYdiXxgENzJy r2yryvyKEfXcEsVaVhB2WTOJObHhebY5pbZ+ZHYraWh/K+dCR7OPJY1HBmsvwTOiHsnW aGpQ8pnSFmQv+ipHFejlm8rIlUFb4TtZwFPUjSSVu+CMEsYpyE8MO4RbBoAsfLqNe1wA 1aB5620HFKkcY+1+hGBbYH//h+TaO1kYkYPxxYW9NiIAMrcvurQuXvW90QLbjSWqozqA 57OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=Pnjy0987JUk+XLq8j9TrVexd3W3Gw7OXJFli75KyJ+4=; b=uLCyddrzD6t0KcutEF+xknkY5ZM7M1pGQL/lep7CvZri4bwQrBe0G+oQ1+eXfARdFF JvKDPZYyvyfH6By8kMK7gnMlsO/pq3sw1CCoqd0w8vLBulPwEKvbVnUyGo9M8pVW63BP YaqfGQTSDBwX9j6kVC2sOvxBiSgLZOUnD0cx3QdndHKt3pEvxcsgtVQECeeYiQflDiw7 7DuYWf4/SeaYf/Tp/Ub+L8BKjAtGv+TknQnjo7ArTvqbsaPMLumBLej9U8Fw2JRZeiiK Waz9vGuBfyR7GhoZ6ODC2HvhjdNbTkDwgRkIurpAAMUMeUVhQ079Fdxii2dsQZ2UUiDH teSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=u64LXe7C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k3si1333404eds.333.2021.04.26.19.23.02; Mon, 26 Apr 2021 19:23:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=u64LXe7C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233932AbhD0CUq (ORCPT + 99 others); Mon, 26 Apr 2021 22:20:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232159AbhD0CUp (ORCPT ); Mon, 26 Apr 2021 22:20:45 -0400 Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C89A6C06175F for ; Mon, 26 Apr 2021 19:20:02 -0700 (PDT) Received: by mail-qt1-x829.google.com with SMTP id d12so5134832qtr.4 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=W+p7PuWM3U3DmC4gnDqWlZNbjnNAJs1oVIaAfqeWyuESBb7u/5cMM1eI+eqLyn+EYm e1ZODNF3yOyYOqyY2Wj73Lss0qwXzYyog29qN3O2Wx7KNrGg33FA4fC0r4bsf7Ks3hlv xvNAVRmAbNTL9q+oafv3cx6Zmgqbj4sCl7ki7pYHNT1qC4io6X9jDe80V6fIElL7MXno 8f7+is/HhU5fNn0/oKmLiarPAP314ZbfVevD+j3nXaiO3YzFWtF874KNSLEddV5eB97P S2XVCS1VzzWpEBXv5hMdiRTWMPJVebEcvDOysMPGXIZNwGag2KKHltae9TC5Ayj4n/+o mwzw== X-Gm-Message-State: AOAM532n/VJVs7/LCuKV1HkfZdzDgi3l6qnUdm5yD5n74rfGH0B/ovHm cbXXQD1tCFiRqkw432nyhVcsoA== 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-kernel@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(-)