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=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 DE11EC433E0 for ; Thu, 25 Feb 2021 20:51:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 540E264E24 for ; Thu, 25 Feb 2021 20:51:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 540E264E24 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8DADF6B0005; Thu, 25 Feb 2021 15:51:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 88BCE6B0006; Thu, 25 Feb 2021 15:51:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7A1946B006C; Thu, 25 Feb 2021 15:51:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0123.hostedemail.com [216.40.44.123]) by kanga.kvack.org (Postfix) with ESMTP id 621116B0005 for ; Thu, 25 Feb 2021 15:51:12 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 257CD1846EF6D for ; Thu, 25 Feb 2021 20:51:12 +0000 (UTC) X-FDA: 77857985184.19.9E77F7E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf30.hostedemail.com (Postfix) with ESMTP id 4AAF9E0001B4 for ; Thu, 25 Feb 2021 20:51:11 +0000 (UTC) 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-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-573-u7Kj0Z22MB-bTkNLsXq2rQ-1; Thu, 25 Feb 2021 15:51:09 -0500 X-MC-Unique: u7Kj0Z22MB-bTkNLsXq2rQ-1 Received: by mail-qv1-f69.google.com with SMTP id t18so5218886qva.6 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=tn4NMQB0j6mXzdj1SNP9a5woNZwuttgELINO5aJDfxNsRVgDWgdAFowtYlBLAlLUQZ 82lS3IEeW7N8Rb/u9eUak/wCG8HVdgfNWWWU2gUPjCODEobGeHa6Hok08/JLNSEmVtCy mJ9Bqm4Vn+nLhHbPmD21FjKHZaRKa6SXun0vAEKpWvHpBHeD3JOpSz2xESOma5SZChxR hPKEdKsuzJvlgZI6wvZ8Q+zqLUY6MfgEiYhkOEaSH9tIp/pZxpK5oUPtL1YGTBFrwq3H PNt5L92ehhGJC+SX5TfhgfBJWIuZw9AJB2lM8B/oqZXn6G0ZvnvAqqvfFQPCGwnR6S75 R2Jg== X-Gm-Message-State: AOAM531j5xetpKzUF+C5YASWsJEwQ4elXfwHvi10skBUV6k3/enXhptr 7H2s+skAlikdq76rzZ1zAXQ1767OttqUsEjydyWCYA4NKJKD1da5FKMEiEv8zpf11Mf+R2I3WZz 64xkl5RhDi7A= X-Received: by 2002:a37:d247:: with SMTP id f68mr4676757qkj.187.1614286267787; Thu, 25 Feb 2021 12:51:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJw5LhdlJsUL0iIi4gSlu38o06OrkQM2ycT5KFnq+Wy5d0l/uDMC6+YahAOSzJOTlEUPreVofA== 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 In-Reply-To: <20210225002658.2021807-5-axelrasmussen@google.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 4AAF9E0001B4 X-Stat-Signature: n5shpc5c3q6of9ugrcwgetq1nd8fjhka Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf30; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=216.205.24.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1614286271-748683 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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