Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp712662pxb; Thu, 25 Feb 2021 13:08:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJzfUFo9AoYmBTpuSvFi5uPRljyJm2hi3varwljVRPmThGlxtZnC42jORKzxUPgtQHFex5OT X-Received: by 2002:a17:906:3556:: with SMTP id s22mr4697240eja.85.1614287288838; Thu, 25 Feb 2021 13:08:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614287288; cv=none; d=google.com; s=arc-20160816; b=Bg4wjXoBzwS1EgPfG7t31EB8alpo+cNPfo9u3KC6pn7iJ61cHO3n9P3yT3jNWgiD2j 7KXRBj7dpInyL5ngLsfkyfnvqANAyBSA1yyfqAcG5daUmpJCfGJrPcvWMsWytrSNr+v+ GXIE60XXugqITQ/9rW/7y17mqyAqBXz/A4U477aXsMkGcfoVnW9kbxwQlVT8NlF8UJeQ MwpF4IF9czge8UPX/CmZy+WYneuOKAh5JVRbGzeW2xDTA8DQdP+TL30u6ow1Uv6bqIED edxN+nYAZ45rMeLNaa/ly8TrpvRUTvsd61QFR9q5nRD+Ry1w5Ky0f562Yt8BQmaFmV1F RWwA== 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=sJgpcpz8JbWE9yNjQ8U8bqTTI3MQeUxSjU+A+WBNGno=; b=L2afCKl6ho0Rs06p1RKZvnEgJ0rVhcA8rQY6oGjdl1QUWR2Zf2ZxL4ZEcoIf2JgWDQ +KNPkUv6QAl9ZkdewBvRcEouoLqf3bTpCXXu+7J6l8vlE34NOU5vfk+Uw4o+Yq89Ui1e OAeNwp57VbFXniN6XNvw9pqZ8rzwvpNNheuqka5EhjHDOml6wdPWcpWEsI9BJDMQNI7s xz02HXpdqIOMvkRlE/KDPoYELXnggwe8hIovkdEKGPHNv/7lSEutF4FUO3LNsNKDEBz4 r7JvhvLF6LK6lwzJckT44QW52dCq+YRoAQwcd3yzlHL4mxDdBTKG/nwyzFqAedoE3ZPf 0/1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aVrpMO9M; 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 d13si4294418edo.367.2021.02.25.13.07.45; Thu, 25 Feb 2021 13:08:08 -0800 (PST) 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=aVrpMO9M; 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 S234494AbhBYVFN (ORCPT + 99 others); Thu, 25 Feb 2021 16:05:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:36245 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234185AbhBYUwg (ORCPT ); Thu, 25 Feb 2021 15:52:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614286270; 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=sJgpcpz8JbWE9yNjQ8U8bqTTI3MQeUxSjU+A+WBNGno=; b=aVrpMO9MZfiSiNqOg6RcwIWEEhjG28i4cE499QQo2pVvM334yo7dt0CeZTFus1ImAP2Kzu mzSaPpjKdQe4u167q/QMGnXw6/ncKEFlr7MNeOKXI4m0iSiODgP2L2mC38PBmU2Dv4GwTs 9HoB51OCiYSZxp52RtnrXNSzgLjBmaU= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-573-E1u8wqDQNoCKP7FghtZUWw-1; Thu, 25 Feb 2021 15:51:09 -0500 X-MC-Unique: E1u8wqDQNoCKP7FghtZUWw-1 Received: by mail-qv1-f70.google.com with SMTP id e10so4097392qvr.17 for ; Thu, 25 Feb 2021 12:51:08 -0800 (PST) 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=sJgpcpz8JbWE9yNjQ8U8bqTTI3MQeUxSjU+A+WBNGno=; b=Uumf9IdJ9XUH243Jv1j//dGRXDiCqXf3VzfnsajZQ32QSXJrBTnjjLBcVFb+piYEMx gznb5naxLPrRmzlyLMV3WtUleESN3L4bAhizDnhy9v+tc74QSWnwbDBVCqkQLInXvWwk ZWfLLXsox+agAiFuHYx3bwUkKMWECOaRBfbL5QczrTFZtd6LaCXSAtK/U6ZFt/8H6CzG 6jTgLpH3r0z0jsNRlJLNZPqxQzhAG/iEN7laP6+bLZM2sQ0BOhfrwH5HlIdRNBj/V0xl vuP+ZGOlPktrlqxrnG+Shb2s0h5Yqt/p/3K/MokpnaWRo/QsSlpZsuyf7LB4CWRcXn8G qp/A== X-Gm-Message-State: AOAM532x6cWfvuxLItiU0r+83ek2WLPvhpHAkne/xoQldhb0AKk1lDz7 kgKLN4Y+k4cZeoOQ70NmXSS/KB2luM82Tqx9PAttjtbgl93zxErFT9HFHKqM7Itwo5mN1Zp/CvH pataAQhqVPL68v+aLInjNyvhQ X-Received: by 2002:a37:d247:: with SMTP id f68mr4676760qkj.187.1614286267787; Thu, 25 Feb 2021 12:51:07 -0800 (PST) X-Received: by 2002:a37:d247:: with SMTP id f68mr4676721qkj.187.1614286267533; Thu, 25 Feb 2021 12:51:07 -0800 (PST) Received: from xz-x1 (bras-vprn-toroon474qw-lp130-25-174-95-95-253.dsl.bell.ca. [174.95.95.253]) by smtp.gmail.com with ESMTPSA id 18sm3820035qkr.77.2021.02.25.12.51.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Feb 2021 12:51:07 -0800 (PST) Date: Thu, 25 Feb 2021 15:51:04 -0500 From: Peter Xu To: Axel Rasmussen Cc: Alexander Viro , Alexey Dobriyan , Andrea Arcangeli , Andrew Morton , Anshuman Khandual , Catalin Marinas , Chinwen Chang , Huang Ying , Ingo Molnar , Jann Horn , Jerome Glisse , Lokesh Gidra , "Matthew Wilcox (Oracle)" , Michael Ellerman , Michal =?utf-8?Q?Koutn=C3=BD?= , Michel Lespinasse , Mike Kravetz , Mike Rapoport , Nicholas Piggin , Shaohua Li , Shawn Anastasio , Steven Rostedt , Steven Price , Vlastimil Babka , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Adam Ruprecht , Cannon Matthews , "Dr . David Alan Gilbert" , David Rientjes , Mina Almasry , Oliver Upton Subject: Re: [PATCH v8 4/6] userfaultfd: add UFFDIO_CONTINUE ioctl Message-ID: <20210225205104.GA261488@xz-x1> References: <20210225002658.2021807-1-axelrasmussen@google.com> <20210225002658.2021807-5-axelrasmussen@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210225002658.2021807-5-axelrasmussen@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 24, 2021 at 04:26:56PM -0800, Axel Rasmussen wrote: > This ioctl is how userspace ought to resolve "minor" userfaults. The > idea is, userspace is notified that a minor fault has occurred. It might > change the contents of the page using its second non-UFFD mapping, or > not. Then, it calls UFFDIO_CONTINUE to tell the kernel "I have ensured > the page contents are correct, carry on setting up the mapping". > > Note that it doesn't make much sense to use UFFDIO_{COPY,ZEROPAGE} for > MINOR registered VMAs. ZEROPAGE maps the VMA to the zero page; but in > the minor fault case, we already have some pre-existing underlying page. > Likewise, UFFDIO_COPY isn't useful if we have a second non-UFFD mapping. > We'd just use memcpy() or similar instead. > > It turns out hugetlb_mcopy_atomic_pte() already does very close to what > we want, if an existing page is provided via `struct page **pagep`. We > already special-case the behavior a bit for the UFFDIO_ZEROPAGE case, so > just extend that design: add an enum for the three modes of operation, > and make the small adjustments needed for the MCOPY_ATOMIC_CONTINUE > case. (Basically, look up the existing page, and avoid adding the > existing page to the page cache or calling set_page_huge_active() on > it.) > > Signed-off-by: Axel Rasmussen Reviewed-by: Peter Xu -- Peter Xu