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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 8718FC4708F for ; Tue, 1 Jun 2021 06:31:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0418060FF0 for ; Tue, 1 Jun 2021 06:31:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0418060FF0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 78C866B006C; Tue, 1 Jun 2021 02:31:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 763A86B006E; Tue, 1 Jun 2021 02:31:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6049B8D0002; Tue, 1 Jun 2021 02:31:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0178.hostedemail.com [216.40.44.178]) by kanga.kvack.org (Postfix) with ESMTP id 3197A6B006C for ; Tue, 1 Jun 2021 02:31:43 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id BA4D7909D for ; Tue, 1 Jun 2021 06:31:42 +0000 (UTC) X-FDA: 78204184044.18.DD84D58 Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) by imf05.hostedemail.com (Postfix) with ESMTP id C41B1E000240 for ; Tue, 1 Jun 2021 06:31:25 +0000 (UTC) Received: by mail-ed1-f48.google.com with SMTP id b17so15976913ede.0 for ; Mon, 31 May 2021 23:31:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mtIHbTQEWZy03u+F/1bX9f+NRkMDtukdZ6wYfFJ5x2k=; b=XgRh5D8kPOBUFMoADvss3cc0DR+uLPy1UvRB6CNpi0uy2MKHLssEm9xlNM8k8vofWB M6H/dPrzWE78mQwAP9igsuCAeZYDAU+LOsg8UtnsTfENk5jFRwd2PYwVN+NzbLsRSOYB 3CBlfXdSCpwLafhzh9ucwlfibNxyaOWr+V0jA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mtIHbTQEWZy03u+F/1bX9f+NRkMDtukdZ6wYfFJ5x2k=; b=lQNKpeqU7GP07hWBy9Uw6agABPhNRJehai8N727WmHQpwv+CJKGUMWuR1JheBIcc7s M58YDC45tX+d94lkOiTWNB5WfEwcCtn2GMns98vJv26umDFGS1H+2UMJC2THHd+U8+hD fjFyWKHERFELJ/HXq0KQ4L0dSU9rTiMNKOYwQCWDOG0Ao4ytEo365pweqybbGbvzrokh /tEiynoNEw7jOVc81BWo2Kqe3CbnXAh3S8yAHrtfp13pjfXB1QKeUVs2MZ6AZfs2y0BT KJLoaMmFz6xr4V1epH/fdYQ7HZTkgRjXU4RzLdWXMgIxozN3lzPc7NAGtlys4spyY7ZH wQ4g== X-Gm-Message-State: AOAM530JSqh3Kxch1I8MdK6OtL/YbfH1fmfRmyMpVxhpV+24C1UtGAfS /77XwQLLuBBV0pSq4kw6Lt+IdWHakRkoPlX8Dpo= X-Google-Smtp-Source: ABdhPJzVACz9UaBYdjATEOu1wDNHbAZOHqY0OtKAvPvf1PRD42B80MWiSeY04Ch87ljSOsgAwUy+rg== X-Received: by 2002:a2e:3311:: with SMTP id d17mr19965435ljc.382.1622528664475; Mon, 31 May 2021 23:24:24 -0700 (PDT) Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com. [209.85.167.50]) by smtp.gmail.com with ESMTPSA id w20sm257997lfu.190.2021.05.31.23.24.23 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 31 May 2021 23:24:24 -0700 (PDT) Received: by mail-lf1-f50.google.com with SMTP id f30so20085922lfj.1 for ; Mon, 31 May 2021 23:24:23 -0700 (PDT) X-Received: by 2002:a05:6512:3f82:: with SMTP id x2mr11385070lfa.421.1622528663766; Mon, 31 May 2021 23:24:23 -0700 (PDT) MIME-Version: 1.0 References: <20210429154807.hptls4vnmq2svuea@box> <20210429183836.GF8339@xz-x1> <7718ec5b-0a9e-ffa6-16f2-bc0b6afbd9ab@gmail.com> <80c87e6b-6050-bf23-2185-ded408df4d0f@gmail.com> <36fc2485-11f1-5252-904d-f26b63a6cd58@gmail.com> In-Reply-To: From: Linus Torvalds Date: Mon, 31 May 2021 20:24:07 -1000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Sealed memfd & no-fault mmap To: Ming Lin Cc: Hugh Dickins , 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" Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=google header.b=XgRh5D8k; spf=temperror (imf05.hostedemail.com: error in processing during lookup of torvalds@linuxfoundation.org: DNS error) smtp.mailfrom=torvalds@linuxfoundation.org; dmarc=temperror reason="server fail" header.from=linux-foundation.org (policy=temperror) X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: C41B1E000240 X-Stat-Signature: c8soekmzj5nheubnp8bj4xtp7tms1a98 X-HE-Tag: 1622529085-930824 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 Mon, May 31, 2021 at 11:13 AM Ming Lin wrote: > > OK, I borrowed code from filemap_xip.c and implemented this behavior. I think that "unmap page" is too complicated and fragile. The only page that could possibly validly be unmapped is a stale zero page, but that code in shmem_unmap_nofault_page() seems to try to handle other cases too (ie that whole page_remove_rmap() - afaik a zero page has no rmap). I get the feeling that the simpler thing to do is to just say "if you use MAP_NOSIGBUS, and you access pages that don't have a backing store, you will get zero pages, and they will NOT BE SYNCHRONIZED with the backing store possibly later being updated". IOW, just document the fact that a MAP_NOSIGBUS mapping isn't coherent wrt shmem contents that are expanded and filled in later. Don't try to "fix" it - because any user that uses MAP_NOSIGBUS had better just accept that it's not compatible with expanding the shmem backing store later. Keep it simple and stupid. Hmm? Linus