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=-9.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 EA84EC4708F for ; Sat, 29 May 2021 23:36:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5F1A660FF3 for ; Sat, 29 May 2021 23:36:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5F1A660FF3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B788E6B0070; Sat, 29 May 2021 19:36:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B2A706B0071; Sat, 29 May 2021 19:36:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9F2B36B0072; Sat, 29 May 2021 19:36:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0060.hostedemail.com [216.40.44.60]) by kanga.kvack.org (Postfix) with ESMTP id 635856B0070 for ; Sat, 29 May 2021 19:36:20 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id EFB3E181AC9C6 for ; Sat, 29 May 2021 23:36:19 +0000 (UTC) X-FDA: 78195879678.27.4695B41 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by imf08.hostedemail.com (Postfix) with ESMTP id C32FF8019355 for ; Sat, 29 May 2021 23:36:09 +0000 (UTC) Received: by mail-pj1-f48.google.com with SMTP id jz2-20020a17090b14c2b0290162cf0b5a35so839342pjb.5 for ; Sat, 29 May 2021 16:36:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=c2WnM1zDO+Y6Htqu0TQxoQ5bjmD0kYCGJDdZojp1i3c=; b=enfSHxkJwnhPLf7LVybONTDL4gh2SRGRUlReeUB2CO4zwhYr2pAAD24zxC6jRDUYQl vHYBQF8chmH4bdHxCIXRKnG1TwGczwpyvE7b4K9DgVA+TpNSZhd8qEO84UCpXPWT4HTT 55+gqD9DIBqTljFIlx+LIOzbiFuN1WSVEUGdzLXEEByY7LjreBX/YNbrLyXvoQu9S76F ObM/ipxp06VoOeMmnscIPReFo8psTiqoYa8l+cKY1PIt6VKR3PZFvcWAdUsTOE8/235f rQZIlXfK1MUA4ZGrcFu/J/OF872FezsybgCmZAq0ARZqGtJDun+KpAh+LOERUVBEPohT WO2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=c2WnM1zDO+Y6Htqu0TQxoQ5bjmD0kYCGJDdZojp1i3c=; b=SRg6l8ksmPq0C44xfv4Y1R2z4VPwR7nAJHG/ZBe6GaMU2iVV9oF7BNSslny/4RSHY7 ODNCGK2qpeCbZaGRTgXmpuh2RjpNXGI/nfTJunr0bf+31T3Z6lISqHHSAHpIVifj7/dw 8vgJWc5U5FdquvawhiqxfmMx3bwd8XA4EsvoPXBCjskvw06cUsMmsZFACPzEhLHgAnjr tcRcpd4s7q7INi+5nV76VnelGRyhlTQBm/oAejbFbOuH+42O82A7XGSLweB67LCuklAd MyNXM0Rgf5HQ/PWt+kOm/oN1xzVbu8p0y8jTGl08TCnBn+iY/nALOweqe9gf9G9Jany4 l9FQ== X-Gm-Message-State: AOAM530Bvx/hhcGTvt59v1GKu9ZW+sOtgqLJMCYNiI4FqbyU5b+DpidB NYE9U/4TLxq6OkWF/WVEX/8= X-Google-Smtp-Source: ABdhPJwf0NK0abdbZJmuEYRFg6s2Ru7boT0tbz7uYaLpjwJPUpJdHFW2iCGSdQawDYo09KeavCyWpA== X-Received: by 2002:a17:903:189:b029:f1:d67a:5168 with SMTP id z9-20020a1709030189b02900f1d67a5168mr14040327plg.82.1622331378465; Sat, 29 May 2021 16:36:18 -0700 (PDT) Received: from ?IPv6:2601:647:5380:8c0:69f7:e9:4598:c206? ([2601:647:5380:8c0:69f7:e9:4598:c206]) by smtp.gmail.com with ESMTPSA id v3sm7298769pfb.203.2021.05.29.16.36.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 29 May 2021 16:36:17 -0700 (PDT) Subject: Re: Sealed memfd & no-fault mmap To: Hugh Dickins , Linus Torvalds Cc: Simon Ser , Peter Xu , "Kirill A. Shutemov" , Matthew Wilcox , Dan Williams , "Kirill A. Shutemov" , Will Deacon , Linux Kernel Mailing List , David Herrmann , "linux-mm@kvack.org" , Greg Kroah-Hartman , "tytso@mit.edu" References: <20210429154807.hptls4vnmq2svuea@box> <20210429183836.GF8339@xz-x1> <7718ec5b-0a9e-ffa6-16f2-bc0b6afbd9ab@gmail.com> <80c87e6b-6050-bf23-2185-ded408df4d0f@gmail.com> From: Ming Lin Message-ID: <36fc2485-11f1-5252-904d-f26b63a6cd58@gmail.com> Date: Sat, 29 May 2021 16:36:14 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=enfSHxkJ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf08.hostedemail.com: domain of minggr@gmail.com designates 209.85.216.48 as permitted sender) smtp.mailfrom=minggr@gmail.com X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: C32FF8019355 X-Stat-Signature: ga7tnn6uxyi461ukr41obykt5md6hfcq X-HE-Tag: 1622331369-575427 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 5/29/2021 1:15 PM, Hugh Dickins wrote: > > NOFAULT? Does BSD use "fault" differently, and in Linux terms we > would say NOSIGBUS to mean the same? > > Can someone point to a specification of BSD's __MAP_NOFAULT? > Searching just found me references to bugs. Checked freebsd and openbsd, their MAP_NOFAULT seems quite different than NOSIGBUS. freebsd: https://github.com/freebsd/freebsd-src MAP_NOFAULT: The mapping should not generate page faults openbsd: https://github.com/openbsd/src __MAP_NOFAULT only makes sense with a backing object > > What mainly worries me about the suggestion is: what happens to the > zero page inserted into NOFAULT mappings, when later a page for that > offset is created and added to page cache? > > Treating it as an opaque blob of zeroes, that stays there ever after, > hiding the subsequent data: easy to implement, but a hack that we would > probably regret. (And I notice that even the quote from David Herrmann > in the original post allows for the possibility that client may want to > expand the object.) Yes, that's problem ... > > I believe the correct behaviour would be to unmap the nofault page > then, allowing the proper page to be faulted in after. That is > certainly doable (the old mm/filemap_xip.c used to do so), but might > get into some awkward race territory, with filesystem dependence > (reminiscent of hole punch, in reverse). shmem could operate that > way, and be the better for it: but I wouldn't want to add that, > without also cleaning away all the shmem_recalc_inode() stuff. After we treat it as zero page, then no page fault for later read. What is the timing to unmap the nofault page? I'm reading filemap_xip.c to learn how to do it. https://elixir.bootlin.com/linux/v3.19.8/source/mm/filemap_xip.c