Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp620242pxy; Wed, 28 Apr 2021 10:36:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYiij1OgvTiCvQ7EnJmAubOB52Z2sIa26+PR858vG6zvDEAofsv7Hrj8664bq2xtX8N87D X-Received: by 2002:a17:906:9a02:: with SMTP id ai2mr9316379ejc.279.1619631413429; Wed, 28 Apr 2021 10:36:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619631413; cv=none; d=google.com; s=arc-20160816; b=GoUtTtEHQu+ahfxW0YoNCw11ZWkE5IIoLQHLsVPTn+Hu7It12/R8gops+cxbh5Z1NP ZJysVDQD/udqVyiZTW4+EPW0mivDH+SjeeB8wttolhlsw17VUxHTWWO9sxySDUAvLiRz R4cQHIVKaop8OGJlFoODDuGw9eqntOZ4A1cDGmpRTXdAgZw67rUiV8x/AmD70TK5npVY 1GwHmMbKXZeLHkSzjcb/SmdFZzwBwOymguGCUuv3B5f9xvAPl0HiAx8+BhmLFSfacThg GyA7r55YsIpTam3z6vpJCdc9Nupz4I6wn/hVAXha5qJguid8br034lxMvwaVwnsAEzAn 8bUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=kk0GXyWrV+tplXlipzE2jcmQ3JfsCy9V2iMdjdCt+G0=; b=xrZ5HGlq0U+b6sZr6WFyXqV7WG0ksQEfdD2Ngvz/R8wCyELQKvCqMslzKJV3ibdB8a KpTmqML0w4xcQdz56GGtgFWcIYBA/x0j6AJeISPScNQerOKmgQjeoya0BSxL0fKjsmQj ZWy5Xt0hGpIRaadicVvy8GY0Q+cPNTTg3RPWrA5RI12BJvncv/szug3EBj3nEBCbQ88t SxpFXhdNVKkLDP6Vv6eG2fPyHOZlpXDEGMzaLG32aM4vRM82UJUF6qce9wr68H0m3/5A iohcPJiPjD2tpGefWVMWmYK7hJz3j+O9mNf9boR9jbSNUj/16Gd38C+oun2JA2AAiZpA bnnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eF+dxnYI; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k9si335889edv.428.2021.04.28.10.36.28; Wed, 28 Apr 2021 10:36:53 -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=@redhat.com header.s=mimecast20190719 header.b=eF+dxnYI; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236514AbhD1PLH (ORCPT + 99 others); Wed, 28 Apr 2021 11:11:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28506 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233738AbhD1PKy (ORCPT ); Wed, 28 Apr 2021 11:10:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619622609; 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: in-reply-to:in-reply-to:references:references; bh=kk0GXyWrV+tplXlipzE2jcmQ3JfsCy9V2iMdjdCt+G0=; b=eF+dxnYIs+ZLj9HBWAJwe0vwC2LlBWGcYDuRVttOYjqcHZrouKAjh3lq5kdcN4IdwojG3e Xh4ne1eTDdd97Fqgp7P5E89TeM+uo1dRcvRCjHeCeL2l28aCReW53gS8ev7X4ilEe3rAV2 GotZzFwCuvf+3Y6oly+PsmYZ+qRh+C4= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-525-qnvFvSKUMruJjw1kh2tfaA-1; Wed, 28 Apr 2021 11:10:07 -0400 X-MC-Unique: qnvFvSKUMruJjw1kh2tfaA-1 Received: by mail-qt1-f199.google.com with SMTP id 10-20020ac8594a0000b02901b9f6ae286fso17481253qtz.23 for ; Wed, 28 Apr 2021 08:10:07 -0700 (PDT) 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:message-id:references :mime-version:content-disposition:in-reply-to; bh=kk0GXyWrV+tplXlipzE2jcmQ3JfsCy9V2iMdjdCt+G0=; b=U06wLNMEUbsdjCM4VSicLbq+04gCoG/2k+JEeZLZBhcff/J4WFbyPJyrjZf53DdEFB nFMguxMdGbERYAtJBKkWY7HqGUqyS9lLtM6drUOZEdwsnKvpqjmkKQRUL40Zcg0DkU+J r3CnLCkHayMYuDUk2ps8N7Bz1bkev4Ay5EdhGTtjXgxud1JazzTXOjGGtxYd5jCtu0bh hfR7uaPi0+4wokxVGMQVEoYQ0NZMO4PqpVCtjaGQGBDsY/FRW+LhzWBQ2Bjkgdy2SDj6 4mLkKUWpGYCAgR8Y+I3csdjvi/Qcz0NkfsQzb1ctoI2+UmGbhdv3sbK2hW9NQiGw1BXV g7qA== X-Gm-Message-State: AOAM530t60RwOS/w6NFi8geGt7yGfR2M4vRxQzPHbkgb9RjGbvUZ2rYN sULAo1f2A0vE1M3ZRKxZuGuj2kIMav7MHjRvL+UwUZ6GzEvOwdgxUrBDtm6jI9NIMxvi929Gqgt cMbwRbARttuEhA8GvPolOcgQA X-Received: by 2002:a05:622a:58d:: with SMTP id c13mr5772736qtb.44.1619622606822; Wed, 28 Apr 2021 08:10:06 -0700 (PDT) X-Received: by 2002:a05:622a:58d:: with SMTP id c13mr5772702qtb.44.1619622606467; Wed, 28 Apr 2021 08:10:06 -0700 (PDT) Received: from xz-x1 (bras-base-toroon474qw-grc-77-184-145-104-227.dsl.bell.ca. [184.145.104.227]) by smtp.gmail.com with ESMTPSA id f2sm5333165qkh.76.2021.04.28.08.10.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 08:10:05 -0700 (PDT) Date: Wed, 28 Apr 2021 11:10:03 -0400 From: Peter Xu To: Axel Rasmussen Cc: Alexander Viro , Andrea Arcangeli , Andrew Morton , Hugh Dickins , Jerome Glisse , Joe Perches , Lokesh Gidra , Mike Kravetz , Mike Rapoport , 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 v5 04/10] userfaultfd/shmem: support UFFDIO_CONTINUE for shmem Message-ID: <20210428151003.GB6584@xz-x1> References: <20210427225244.4326-1-axelrasmussen@google.com> <20210427225244.4326-5-axelrasmussen@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210427225244.4326-5-axelrasmussen@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 27, 2021 at 03:52:38PM -0700, 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 Acked-by: Peter Xu -- Peter Xu