Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1513454pxj; Sat, 29 May 2021 16:44:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHH6ogai9uU65u6LGUBnwTWPG+Aynd+D0dl7oyZ2xFMaHE2OSXnIl7oynSsa6OfKDJnb4w X-Received: by 2002:a02:a19c:: with SMTP id n28mr14758890jah.117.1622331846852; Sat, 29 May 2021 16:44:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622331846; cv=none; d=google.com; s=arc-20160816; b=p3/0XWO9kBXVOKjK8FppiGreJ+R3Um9v2ew9sVGu1BHvoQ5eXQ73I0r69ylsOhAkGu bE46E21lSXpqicDBxWNxj4cTmvkGZzukUbTPSGy2iaKUp9qo5IFwXyNpzoE0oILNQXFS X+eVJuE3Eo1ANafIZtGmpkICxtx/cZ1NUdMpIdMsgPPZze3CrUpQpSSj52yzxuDgxUCt uUzo6dzgFK4eWdMuu1t1esCbCkKGNN6pbAshk9Icgz1UFhVE8++ZybLf/GcrKofNOgbt K3IucU/WcPmIj+AqPN8sAB8+GxtBord2hlyBfvj5Mz08KQJoc2S3V2qE+yV/NDOTqQgy 25GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=c2WnM1zDO+Y6Htqu0TQxoQ5bjmD0kYCGJDdZojp1i3c=; b=RErNmqdAyalxF2ijTyLMZBZUEvCgPoOHu1gCpm5lE08B9AFyQJ7R9JsuBMd/hddkzg Qn5dqg0QTbqbCJnU4pKLz5h5fy34Eu399405lN+udX90VtdgoFdAvmTvv40kyNTFxs17 L6N/MKLneVlWUkzoEWc3GeykiTlrAPXZDMzEkQvAvgEQ8PSDkWhe1w0Ilw5DSZeqAJcb 783KvAiM7RspAlmAkdWQpVWcfAvH17f18vEzrfH183Xei8gI2lPqyrSAzn9k0dgu6orn alHVY7fZwtPmDWLZ/BFloE6yYqrFPxM0ORwaySvuBXUh702oBHJU6MzXlQps1x3W0aXG E/yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=enfSHxkJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h26si9268203ila.93.2021.05.29.16.43.53; Sat, 29 May 2021 16:44:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=enfSHxkJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229583AbhE2Xh4 (ORCPT + 99 others); Sat, 29 May 2021 19:37:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229514AbhE2Xh4 (ORCPT ); Sat, 29 May 2021 19:37:56 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2501AC061574 for ; Sat, 29 May 2021 16:36:19 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id b15-20020a17090a550fb029015dad75163dso4591441pji.0 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=ToLocKZMUdkh2fAev59svf0UiKkso7viece4IcKaV0/OzEvOu0u/18eAN5FzRtuuem 3+bMLupopt4wF+qQAd+bQyuz7LguMK4jh/fdBhJotIvt0rJpun/ICmkLFSkAvuM0lB1m DYed5Gb9Ax0CiRLNN0DM+VcaD1IATtERWCrK0QGZ7GNBQEU0mDw9TJrf389AblayZHMr jt7sHX9p706PE9ZMrU5h9VZBUOcdI1tK8kOw94UiGRRnGz5l5EnMkYjFkEkzRm3EaOHg RfUuregToU7wpyJcKDRQ66XUy3w2lm5HhsMSKt/fCy1nW/+D6rfjrZANIfKN9ZObdDdk k76A== X-Gm-Message-State: AOAM5326xUiowNAqghd+yWj2TA9lObXUNcC2mrasmqcGMkSwqgQdmtWB DP2VbbWClEoqYWkYUOt6zLM= 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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