Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1042159pxf; Thu, 18 Mar 2021 19:05:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwF9IQRzw6diuBC2+Ek5Ame85o882TCXfFSXE0H3nsc9mIRvtulAGoFIfR4YWJ4t9iTVA/6 X-Received: by 2002:a50:fa42:: with SMTP id c2mr7124603edq.159.1616119530898; Thu, 18 Mar 2021 19:05:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616119530; cv=none; d=google.com; s=arc-20160816; b=RPdi2AFe2ovSfBeG2dZ6PctfGsCk4Sf1UxDbK1+2WEfJdiPwjVzWZ11xX8YPN7yEmx 1KMWqpEiANX+/lNSkin5iyDlAnAc3Dqvj0qYn6KzRuZESxpye9lWvODbekFFtU6OR+h0 99IFH9QaM8thx6aZknCLMWtFZdiIxolIV2Wzrxqv92hcy9lYQdcpnCcuv9oHAUrvdjpw jjE6myXlCUq3wLFBoyxUJgm3NXj3OuDe7iMy3IZ+vQy42FML3ioXoENdImR83Gksrn2N Pv06pmCF4XCaTQYb5EPr1XI64n1R71wQ/phZoX2PCfYrnDf8ThjlX9IIOdE/qmi2y6iq qIIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=JiVqDCFQoleLcPQiijGmNpe+GDIBYP9KaktrAuD4UeY=; b=XGBkXNvXYxQI6TAriGi7Y+RYTnHaHjZc7uOPBiofH7R7kOuzgITZH2U5OSYa8qQuHQ lcKqasfhPtsmWk7382zoPAGzALox99y5ID20e87q8uckuFMRbJfrqCz+JE+Mt9NWXBPo JeUDHN+r8M6OhKvWQJBdp0BiFKqmijT4hTsQoOgd7AxKxWMRkBGRQWKmq0wJmRqQmx36 stkx0SW3kCYTNfi6ijlsCypo+Pf0L8Ipe60dTwIqanCwfRFbjXUohsuwhOmG0ES8czjj rvv64Banmp/D167aqVmj2DcOwAuXXVVjywsjSCQx8a2GL95Luzrarm7RFw1wwA7JXl5D JH9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=cO4PvwPZ; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jl16si3068610ejc.330.2021.03.18.19.05.08; Thu, 18 Mar 2021 19:05:30 -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=@google.com header.s=20161025 header.b=cO4PvwPZ; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231161AbhCSB6v (ORCPT + 99 others); Thu, 18 Mar 2021 21:58:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230119AbhCSB62 (ORCPT ); Thu, 18 Mar 2021 21:58:28 -0400 Received: from mail-qv1-xf35.google.com (mail-qv1-xf35.google.com [IPv6:2607:f8b0:4864:20::f35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08B73C06174A for ; Thu, 18 Mar 2021 18:58:28 -0700 (PDT) Received: by mail-qv1-xf35.google.com with SMTP id 30so4267613qva.9 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=rhmPZS3cRXedTOTESf7yUD0BoaAdPOIzjkhzdvwUHumGwcNT46RcyB3488M6d4snIV rdf1M6f44l5BYxBixpm48tZDsWveJlfSI5jihUttQTdDiyR9XBkR9cwjfxAb6f4g34UM qS8D0futd1jYJM0TBvlks/5nLCAb6zpQx3N3Wlb2VQtCTGOCnvHZDlTzXti/m7NCfdsa /V588swDRRqfzoidBe0uKbnv3AgsQQqIIwwuEKd9wMUFmGHYFwnoWM1LMpIQTGoZfaS7 bEaaW4z0bxI2U9ioIDCCXcngUK2hMtlj4z/L5XwdrjKrUDXKXEQV8zYO63jSAsBG0rNj DJYg== X-Gm-Message-State: AOAM533CwS9ivzjT/1DI7XZaBgJON+9smFN+kp8D4WOPFpgZsxpOYv8S QY6Mo9sEBsWr3YU/YXUCwYmuJQ== 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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