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=-0.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, 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 813E7C32771 for ; Thu, 23 Jan 2020 03:02:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1EB1224125 for ; Thu, 23 Jan 2020 03:02:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=amacapital-net.20150623.gappssmtp.com header.i=@amacapital-net.20150623.gappssmtp.com header.b="J6gYOfoW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1EB1224125 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amacapital.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 84F0A6B0003; Wed, 22 Jan 2020 22:02:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7FE2A6B0005; Wed, 22 Jan 2020 22:02:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 714F26B0006; Wed, 22 Jan 2020 22:02:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0165.hostedemail.com [216.40.44.165]) by kanga.kvack.org (Postfix) with ESMTP id 5C2CD6B0003 for ; Wed, 22 Jan 2020 22:02:14 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 0C059180AD804 for ; Thu, 23 Jan 2020 03:02:14 +0000 (UTC) X-FDA: 76407400188.28.curve84_4d9e75917ed46 X-HE-Tag: curve84_4d9e75917ed46 X-Filterd-Recvd-Size: 5423 Received: from mail-pj1-f67.google.com (mail-pj1-f67.google.com [209.85.216.67]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Thu, 23 Jan 2020 03:02:13 +0000 (UTC) Received: by mail-pj1-f67.google.com with SMTP id n59so546401pjb.1 for ; Wed, 22 Jan 2020 19:02:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=content-transfer-encoding:from:mime-version:subject:date:message-id :references:cc:in-reply-to:to; bh=QHwD3xJbxA6Bj+Yx1EYQsUkr/yHSHTopSLaHf+HB1LQ=; b=J6gYOfoWW7D94l0Y7ebAoY3D9qsp2ivY4bRoViRNM2t+ygjSQ7c98hfo1U/XlqYySc JojfwPv88Mja6A6xQTlrtoPOT36SxrfCvfj3t5/EqQfJCxSo0NcL1czveIgtaa7lDe95 L+vwHoDMjlgDTN7MvU7EIxsiGv1L9+qITCvUNfrbshL2PKCeiVc7vZB3qVeSzAkQSp+S 8VGp43i/tm1uGMM+3zQEztlAgfEXgCGnbBuZ/2w1MEV7J62DVCLiS10G//0E58+SgMsx w946YabfAyizOwSP6vU1vxY35l/0xrrc1X+/j0QklraJ0iAJO6pkB3c74LgNhr3Brd1z 5FJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=QHwD3xJbxA6Bj+Yx1EYQsUkr/yHSHTopSLaHf+HB1LQ=; b=Oefj1AdHJ1HwjQNt+9Nybg2LvszFvuSTRddNxSHZgc49sjSTswT/o8OImMcQs5tedi R0s/AFjW6cq9VMt0GEDN4DBxjYqlhDwUcc14WM9XCsAeziw/f5wLQmzabbBJHDH+dhuV 7F+kRCuSXVEMGe5CTlpWcLX782uvTsj9PWCrepS5ZRonZFG4/jad6BY/vuuyVlOn8D/l tnfSjWN619G3tQ0wkpkCIcpbKQqtUd+ACv9+vX/HTEU6gQ4o4TnOjgossyCx44VTi6oM ydxzRW97hYdaDv5+K+VoyWv3GtceKDjjxeksPeSIjuzxkEDx4jfbrrY+2UEaOzNa+EuJ 8JGA== X-Gm-Message-State: APjAAAV6l0mlbQ7VwlVh/T3t+OM03ec832H/ZdVylS7lJ5El9SZ7hZS4 xzxo8luAXElUjkhSzKdJSoqz2Q== X-Google-Smtp-Source: APXvYqx0ztp78PhfwAEOpZE9YOyLcEj6xDbpjw3B4QFYco9brX2bu9A5MvQuDHkORMpB6ZNtfDJ0aw== X-Received: by 2002:a17:90a:5215:: with SMTP id v21mr2014316pjh.31.1579748532131; Wed, 22 Jan 2020 19:02:12 -0800 (PST) Received: from ?IPv6:2600:1010:b025:c4e4:c9ce:11e3:9a9e:90f0? ([2600:1010:b025:c4e4:c9ce:11e3:9a9e:90f0]) by smtp.gmail.com with ESMTPSA id y203sm312460pfb.65.2020.01.22.19.02.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Jan 2020 19:02:11 -0800 (PST) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Andy Lutomirski Mime-Version: 1.0 (1.0) Subject: Re: [PATCH] mm: Add MREMAP_DONTUNMAP to mremap(). Date: Wed, 22 Jan 2020 19:02:08 -0800 Message-Id: References: <20200123014627.71720-1-bgeffon@google.com> Cc: linux-mm@kvack.org, Andrew Morton , "Michael S . Tsirkin" , Arnd Bergmann , Sonny Rao , Minchan Kim , Joel Fernandes , Lokesh Gidra , linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Yu Zhao , Jesse Barnes In-Reply-To: <20200123014627.71720-1-bgeffon@google.com> To: Brian Geffon X-Mailer: iPhone Mail (17C54) 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 Jan 22, 2020, at 5:46 PM, Brian Geffon wrote: >=20 > =EF=BB=BFMREMAP_DONTUNMAP is an additional flag that can be used with > MREMAP_FIXED to move a mapping to a new address. Normally, mremap(2) > would then tear down the old vma so subsequent accesses to the vma > cause a segfault. However, with this new flag it will keep the old > vma with zapping PTEs so any access to the old VMA after that point > will result in a pagefault. This needs a vastly better description. Perhaps: When remapping an anonymous, private mapping, if MREMAP_DONTUNMAP is set, th= e source mapping will not be removed. Instead it will be cleared as if a bra= nd new anonymous, private mapping had been created atomically as part of the= mremap() call. If a userfaultfd was watching the source, it will continue t= o watch the new mapping. For a mapping that is shared or not anonymous, MRE= MAP_DONTUNMAP will cause the mremap() call to fail. Or is it something else? >=20 > This feature will find a use in ChromeOS along with userfaultfd. > Specifically we will want to register a VMA with userfaultfd and then > pull it out from under a running process. By using MREMAP_DONTUNMAP we > don't have to worry about mprotecting and then potentially racing with > VMA permission changes from a running process. Does this mean you yank it out but you want to replace it simultaneously? >=20 > This feature also has a use case in Android, Lokesh Gidra has said > that "As part of using userfaultfd for GC, We'll have to move the physical= > pages of the java heap to a separate location. For this purpose mremap > will be used. Without the MREMAP_DONTUNMAP flag, when I mremap the java > heap, its virtual mapping will be removed as well. Therefore, we'll > require performing mmap immediately after. This is not only time consuming= > but also opens a time window where a native thread may call mmap and > reserve the java heap's address range for its own usage. This flag > solves the problem." Cute.=