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=-3.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no 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 9DC90C2D0E4 for ; Fri, 27 Nov 2020 12:22:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A1AD521D93 for ; Fri, 27 Nov 2020 12:22:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="XpQwbtkU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A1AD521D93 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id AC1C96B0068; Fri, 27 Nov 2020 07:22:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A71646B006C; Fri, 27 Nov 2020 07:22:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 987506B006E; Fri, 27 Nov 2020 07:22:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0103.hostedemail.com [216.40.44.103]) by kanga.kvack.org (Postfix) with ESMTP id 7FEEA6B0068 for ; Fri, 27 Nov 2020 07:22:32 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 421AB181AEF32 for ; Fri, 27 Nov 2020 12:22:32 +0000 (UTC) X-FDA: 77530111344.04.music08_241808127387 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 214AF801325F for ; Fri, 27 Nov 2020 12:22:32 +0000 (UTC) X-HE-Tag: music08_241808127387 X-Filterd-Recvd-Size: 3421 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Fri, 27 Nov 2020 12:22:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=choHEX39fwjvIHdfjuTPrJ1YjikPg/jnYxn1TmDtc0c=; b=XpQwbtkUZlyFEyFnSy6qiJsW4P 3MfAz2eBtzlGpJBA/yFDWeCxb48hdRy+zC5dNmxXJnzZMvqoz0z5j4gEe2sKOXmf2Xk1mqRSo0o6/ 4uMIEJ1ODrhQ/lCU2Az3OY1wTo+KU/9nFoRVuS5ABU4ZMUUVy8DLQTCkSp9buLpv0THNUGkxYw0MV /WVL8SDXzVQ8ahtpRWWhHxgNxGuGJBb9eDNRaQQqY1AHTkiLIoubF0jDtayOpHgC1ihosx4yxboYi sAJziN1MN7uvsRYqvZ7UGR6OAbsJJpVz+fzoQsc91p+s8Z/rP8BWt8uMzRSOYRwspGW9BqFSMXc6t KUrHVqug==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kicld-0003jP-23; Fri, 27 Nov 2020 12:22:25 +0000 Date: Fri, 27 Nov 2020 12:22:24 +0000 From: Matthew Wilcox To: Peter Xu Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Hugh Dickins , Andrea Arcangeli , Mike Rapoport Subject: Re: [PATCH] mm: Don't fault around userfaultfd-registered regions on reads Message-ID: <20201127122224.GX4327@casper.infradead.org> References: <20201126222359.8120-1-peterx@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201126222359.8120-1-peterx@redhat.com> 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 Thu, Nov 26, 2020 at 05:23:59PM -0500, Peter Xu wrote: > For missing mode uffds, fault around does not help because if the page cache > existed, then the page should be there already. If the page cache is not > there, nothing else we can do, either. If the fault-around code is destined to > be helpless for userfault-missing vmas, then ideally we can skip it. But it might have been faulted into the cache by another task, so skipping it is bad. > For wr-protected mode uffds, errornously fault in those pages around could lead > to threads accessing the pages without uffd server's awareness. For example, > when punching holes on uffd-wp registered shmem regions, we'll first try to > unmap all the pages before evicting the page cache but without locking the > page (please refer to shmem_fallocate(), where unmap_mapping_range() is called > before shmem_truncate_range()). When fault-around happens near a hole being > punched, we might errornously fault in the "holes" right before it will be > punched. Then there's a small window before the page cache was finally > dropped, and after the page will be writable again (NOTE: the uffd-wp protect > information is totally lost due to the pre-unmap in shmem_fallocate(), so the > page can be writable within the small window). That's severe data loss. Sounds like you have a missing page_mkwrite implementation. > This patch comes from debugging a data loss issue when working on the uffd-wp > support on shmem/hugetlbfs. I posted this out for early review and comments, > but also because it should already start to benefit missing mode userfaultfd to > avoid trying to fault around on reads. A measurable difference?