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=-19.8 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1,USER_IN_DEF_DKIM_WL 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 2061BC433DB for ; Fri, 19 Mar 2021 01:58:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7081164E99 for ; Fri, 19 Mar 2021 01:58:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7081164E99 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 C2FF46B006C; Thu, 18 Mar 2021 21:58:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BDEF86B0071; Thu, 18 Mar 2021 21:58:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A0B826B0072; Thu, 18 Mar 2021 21:58:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0084.hostedemail.com [216.40.44.84]) by kanga.kvack.org (Postfix) with ESMTP id 7CEB36B006C for ; Thu, 18 Mar 2021 21:58:28 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 3BADD249F for ; Fri, 19 Mar 2021 01:58:28 +0000 (UTC) X-FDA: 77934964296.08.BBEA5F8 Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) by imf12.hostedemail.com (Postfix) with ESMTP id BBF4D12E for ; Fri, 19 Mar 2021 01:58:27 +0000 (UTC) Received: by mail-qv1-f51.google.com with SMTP id d10so4288706qve.7 for ; Thu, 18 Mar 2021 18:58:27 -0700 (PDT) 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=JiVqDCFQoleLcPQiijGmNpe+GDIBYP9KaktrAuD4UeY=; b=cO4PvwPZhiVCZOO4Js5LQU0t1J6I3JMpIhjSa3v6KeWVX0N9Izb3Uaa/eNRzjBejAQ CwhTjbcdbJILCsEXAeNH42ehWKmLUTkUoygEsZMz505VcW28OuzdB6qsqecnHk09Gyk9 n+fI627jA2k5LPfSahTJ7iCKBmyf7oKOfCmOURgm/QGUUyKdpXDS8cWF/4kNobXdha9C SBuPLQ/4d1uS8Md3wIH6qKhBCxw7yCKB4uSP4JfCXG1X4vLD9m2D1bRWVFc38Pre3Kmw A3ahxOj2z/+ZkvcCXFCejzpuAH9UK+gIY/xh1cXlkj2MLeZ/1tNc6pJRMK7z6wBkCuT6 vWig== 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=JiVqDCFQoleLcPQiijGmNpe+GDIBYP9KaktrAuD4UeY=; b=IxHA8GJpX+t0DlxJ+pYj0Wxd3/btZ3/+vQ5c/hrBSe+bs+iND2ZY0dq9T2/6ewu97r popTE/B3fL0fcOLQxNqavH2FH2amPn0aJ90TELBKQJvzBv+1oeZ5NJCuM4VLmEmY5fVQ WBwhX+Zs+0GSMFNZQLt1btBzftuS6PaFWZw5Ga1dJ/c6ZluDs94aAcx2d+Gv96fqcFlF DZpkG7D5MtBR0NxNzne2UAVMJn14WCZX4/xq2hRpaqvNoJs91yILGOpjIq6cydZMJwOG xCFDKh6PuHyaYV9diG2AgeWu8kCdAU9AjE6KdZstAPF7VzAyH6IKN5XehBEaMkNcQaQY G3Ag== X-Gm-Message-State: AOAM531po6yOhFSJsiz3t9gV/lRA0TPnWCLcemNMgoA7U+3sHD3QTBKf rRJ3hqreCb5rpdX5VzEQObNfVQ== X-Google-Smtp-Source: ABdhPJwlcAocbwXbejNeQSSFfnPBhhYBU6u5C6+yT1lL+Fw+uGkbTnq8GUvnMW21Yldql/4+R6gHBw== X-Received: by 2002:a05:6214:268c:: with SMTP id gm12mr7129538qvb.36.1616119106845; Thu, 18 Mar 2021 18:58:26 -0700 (PDT) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id f27sm3177041qkh.118.2021.03.18.18.58.24 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Thu, 18 Mar 2021 18:58:26 -0700 (PDT) Date: Thu, 18 Mar 2021 18:58:23 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Peter Xu cc: Hugh Dickins , Brian Geffon , Andrew Morton , Axel Rasmussen , Lokesh Gidra , Mike Rapoport , "Michael S . Tsirkin" , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andy Lutomirski , Vlastimil Babka , Andrea Arcangeli , Sonny Rao , Minchan Kim , "Kirill A . Shutemov" , Dmitry Safonov , Michael Kerrisk , Alejandro Colomar Subject: Re: [PATCH] mm: Allow shmem mappings with MREMAP_DONTUNMAP In-Reply-To: <20210316201732.GD395976@xz-x1> Message-ID: References: <20210303175235.3308220-1-bgeffon@google.com> <20210316201732.GD395976@xz-x1> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Stat-Signature: xe6pej4bjt5z8extsn96npy11ji96jfz X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: BBF4D12E Received-SPF: none (google.com>: No applicable sender policy available) receiver=imf12; identity=mailfrom; envelope-from=""; helo=mail-qv1-f51.google.com; client-ip=209.85.219.51 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616119107-508154 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, 16 Mar 2021, Peter Xu wrote: > > I'm curious whether it's okay to expand MREMAP_DONTUNMAP to PFNMAP too.. > E.g. vfio maps device MMIO regions with both VM_DONTEXPAND|VM_PFNMAP, to me it > makes sense to allow the userspace to get such MMIO region remapped/duplicated > somewhere else as long as the size won't change. With the strict check as > above we kill all those possibilities. > > Though in that case we'll still need commits like cd544fd1dc92 to protect any > customized ->mremap() when they're not supported. It would take me many hours to arrive at a conclusion on that: I'm going to spend the time differently, and let whoever ends up wanting MREMAP_DONTUNMAP on a VM_PFNMAP area research the safety of that for existing users. I did look to see what added VM_PFNMAP to the original VM_DONTEXPAND: v2.6.15 commit 4d7672b46244abffea1953e55688c0ea143dd617 Author: Linus Torvalds Date: Fri Dec 16 10:21:23 2005 -0800 Make sure we copy pages inserted with "vm_insert_page()" on fork The logic that decides that a fork() might be able to avoid copying a VM area when it can be re-created by page faults didn't know about the new vm_insert_page() case. Also make some things a bit more anal wrt VM_PFNMAP. Pointed out by Hugh Dickins Signed-off-by: Linus Torvalds So apparently I do bear some anal responsibility. My concern seems to have been that in those days an unexpected page fault in a special driver area would end up allocating an anonymous page, which would never get freed later. Nowadays it looks like there's a SIGBUS for the equivalent situation. So probably VM_DONTEXPAND is less important than it was, and the additional VM_PFNMAP safety net no longer necessary, and you could strip it out of the old size check and Brian's new dontunmap check. But I give no guarantee: I don't know VM_PFNMAP users at all well. Hugh