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=-14.8 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1, USER_IN_DEF_DKIM_WL 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 1026CC64E7B for ; Wed, 2 Dec 2020 22:37:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 51DEC221F7 for ; Wed, 2 Dec 2020 22:37:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 51DEC221F7 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 394A76B005C; Wed, 2 Dec 2020 17:37:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 345506B005D; Wed, 2 Dec 2020 17:37:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1E5836B0068; Wed, 2 Dec 2020 17:37:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0186.hostedemail.com [216.40.44.186]) by kanga.kvack.org (Postfix) with ESMTP id 039E16B005C for ; Wed, 2 Dec 2020 17:37:49 -0500 (EST) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id BAC2A3626 for ; Wed, 2 Dec 2020 22:37:49 +0000 (UTC) X-FDA: 77549805858.05.pet83_060ec7c273b6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin05.hostedemail.com (Postfix) with ESMTP id 99BD918029121 for ; Wed, 2 Dec 2020 22:37:49 +0000 (UTC) X-HE-Tag: pet83_060ec7c273b6 X-Filterd-Recvd-Size: 4347 Received: from mail-ot1-f66.google.com (mail-ot1-f66.google.com [209.85.210.66]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Wed, 2 Dec 2020 22:37:49 +0000 (UTC) Received: by mail-ot1-f66.google.com with SMTP id f12so3199577oto.10 for ; Wed, 02 Dec 2020 14:37:49 -0800 (PST) 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=IIxg209gF2HmcDmIfCti2CITWbBgmANl1tS9JOtM/5U=; b=VkArJcQmdYMjQ8w3gfZvfQV2YDqYCUOQ6rSxk8sYJyCOzSEGIQcmJYJYZZsg5D16Vn 1RzCtdAHzW9rosgW8WjR6xj+ftciNDTW19uQ4YRjsdNJGA2oOYJs0cLzmRV9x6oOY/zC uX1qxqvcWYOObGSQpys2tcnkz37ZfoLOf9fiZv3ZnIqs5m4Ezh1iwySB7R1dTkgWhO4e GAH1rQeXltcPRouIyvZeUIivIBT7FSWlSGLDiB6u5b2ppQmLtMQNSQSLX4/ygpT91b9n 9Fey05ody2M67J/QPge1AuoZqXHJqQ4Kf3262Nyn98dok3qY7iQ2sco3GOky4Nl3Y9HI WOzQ== 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=IIxg209gF2HmcDmIfCti2CITWbBgmANl1tS9JOtM/5U=; b=s4D5VztSupRHtTvy8oXmjdc18yrUjbXzE9BhmASnCSdZkEU4+LJBZjHNiCJC5VosUQ J/CLFfKQ5OVx79UbWs9C8/5MO3dikFw2Gp50rc5g6oSnhnBFokAsx0eqyZ5EpdcGUxiY gg0fc9QwisQebSbqPERmDtrgafqBDcbwZr8mvzzJc3Ay85ZBcC3Qtx6dQHTRCLRg7h6N k5TcZzB8eT5b+tx99pXI3/hIs0oZ+GQ9XYWVOfQSkQYUMalra4iIV5Jb9x7GCzUSmKWk l2SvdeDZtfomJO1mqZC0uqPtl+3OKOZO4CUPYr54xp668GChGyDWEYCeg55h1PJvM5RY bRhA== X-Gm-Message-State: AOAM530WOfNKH19Sz4sPeiaumgCCW4nOhdQ1Gj+98Y7A27DH2rc0YmW8 m8KE78JIVK9Ud2+HHKIuRhrxeg== X-Google-Smtp-Source: ABdhPJzxJf6nNp8vI4/lnSI0sb8Bwwx6yGSy2pISFbJlqBPxUjzyR0jvVIlPwpD+yP2+rJZ1SjVy9Q== X-Received: by 2002:a9d:68c3:: with SMTP id i3mr64477oto.31.1606948668257; Wed, 02 Dec 2020 14:37:48 -0800 (PST) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id e8sm33488oti.76.2020.12.02.14.37.47 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Wed, 02 Dec 2020 14:37:47 -0800 (PST) Date: Wed, 2 Dec 2020 14:37:33 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Andrea Arcangeli cc: Peter Xu , Matthew Wilcox , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Hugh Dickins , Mike Rapoport , David Hildenbrand Subject: Re: [PATCH v2] mm: Don't fault around userfaultfd-registered regions on reads In-Reply-To: Message-ID: References: <20201130230603.46187-1-peterx@redhat.com> <20201201125927.GB11935@casper.infradead.org> <20201201223033.GG3277@xz-x1> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 Tue, 1 Dec 2020, Andrea Arcangeli wrote: > > Any suggestions on how to have the per-vaddr per-mm _PAGE_UFFD_WP bit > survive the pte invalidates in a way that remains associated to a > certain vaddr in a single mm (so it can shoot itself in the foot if it > wants, but it can't interfere with all other mm sharing the shmem > file) would be welcome... I think it has to be a new variety of swap-like non_swap_entry() pte, see include/linux/swapops.h. Anything else would be more troublesome. Search for non_swap_entry and for migration_entry, to find places that might need to learn about this new variety. IIUC you only need a single value, no need to carve out another whole swp_type: could probably be swp_offset 0 of any swp_type other than 0. Note that fork's copy_page_range() does not "copy ptes where a page fault will fill them correctly", so would in effect put a pte_none into the child where the parent has this uffd_wp entry. I don't know anything about uffd versus fork, whether that would pose a problem. Hugh