Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5405747ybv; Tue, 11 Feb 2020 15:14:53 -0800 (PST) X-Google-Smtp-Source: APXvYqyRRmBzK/Ohz+V+nzbMpfrKKwMKP07Q/80WJF7oAN/QhPC14QRO7JVJ6e1kmxgL+kr2CTZy X-Received: by 2002:a05:6830:158:: with SMTP id j24mr7326660otp.316.1581462893574; Tue, 11 Feb 2020 15:14:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581462893; cv=none; d=google.com; s=arc-20160816; b=rJjuzOKlWlTk/mH8TABs8vF7p/jYx6tJoAZfth9RSkkXtHwRl5xj32aqjXBd3nYDR2 +tGUajvE0Bep9JLH7vRDdI5XxH6RLL6XoXYoBu6c69DG8m6cazSlybHQDL2ig0/6hseL dQkB71qeYZdE2oBT/N/ZE12BwTKDgmnV/jazOqubnHGMhXGXebiKcXfKFNiZYKUPJR53 fE47P9L23RS6uT9yfYC+uO9QB9bX3k2uxAGaidCne+LiqT6wAPexkTsYYxy8m3uckaio Xdd6ChaTVuyAozIUI+P35wPoc0sZm4Qw+d4Q7i+KO22jg5jxkUZdNueCWVP685PqhccQ PaJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=XYjvLHVV907LS6rizJ9ULRVH4X6ax5Sri5cvG4NYaz4=; b=cm88+zbddTxmmYSIS+Qcibdgnu/n+znGqlrXpG73Z4uzOXuok/JMYDY8S2gSBiFZUa pn64X0ZeyBX9nr2AOMu6kTbXVrVDA5V6pPR9wckZwxxsLSaC7rsTnThcYlZBdPFeL10T Mca1m2oRUaFfZg5K1sfR8kbAODGH/19TRILhHF+aSXgRsVYvGmTSEeVwO2edAJz7E/J6 NJHtS81tXgCOv4WLsUqlL6QiP8/S0xQ5Mld787Fzs0+IPgR6kb19rT3si6VCnrvVRT3g IunhhxyygPOsqES/z+lY6oZxVNH78JERd1gPALjfqqH30ycEK9Yo4RRLc8Wu7Y6M7CA+ ArxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=JnjsbJjr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id r6si2721734otp.220.2020.02.11.15.14.40; Tue, 11 Feb 2020 15:14:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=JnjsbJjr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727989AbgBKXO3 (ORCPT + 99 others); Tue, 11 Feb 2020 18:14:29 -0500 Received: from mail-ot1-f68.google.com ([209.85.210.68]:33193 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727821AbgBKXO1 (ORCPT ); Tue, 11 Feb 2020 18:14:27 -0500 Received: by mail-ot1-f68.google.com with SMTP id b18so57978otp.0 for ; Tue, 11 Feb 2020 15:14:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=XYjvLHVV907LS6rizJ9ULRVH4X6ax5Sri5cvG4NYaz4=; b=JnjsbJjrdrrIojmvFgroniN5i1GKnfaaT41kAs8h31h6aBdobmBv21NJ2AzZKmxCBP MLWB5g13J5W8UqhsPL3tkNWBlVkv2fMJvtzHJTRoKrnj9kRQm+/c8N2K1xWT2LY/OYSx XQxsLHqLwj2HHw5KWDL+QSv1aFa1L0M9vxqJxO/pOlrh3EmVsXzZ3vmQtjazz5j6vTWJ SrEXDDoofENJcJjikoZ4j8O+gppW5E/0x+GsaioBQ7qBFCo2QsnV0+RB7feb6mToWr6H I9WaclXthNe0rF86nMTezsx9mt6IWT1Ito8+T/DCMoi1KiS9SKlGYu65G9W9mc38TfO+ p3Ng== 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=XYjvLHVV907LS6rizJ9ULRVH4X6ax5Sri5cvG4NYaz4=; b=V102KIMtBcdJ8adDpaFkllq3+YqWpA1447S1VhC+raeKyqLKXH4qAFL2wLloOWxZvW hxXCQUc/pdYqIGobtJ6vL611268dhDVsrM1jwponhTDz8cjensTiSXc8IQ6MvTKXQyks /Mr0w1eLByi5UNszGOTTLnR19XfIY55Uy+E2q8mN4+qQGhnFMeuAR+yW+mt5Plwnyyzw +p5xwr/JDI1eksVqrXBdZInjmey3gwTC6jckUEq8iMUFKZiPJQ+EW0/zjrlFKkRhNc2a vC+oDgyhqGJCir8AKfCzpRIH3USYPJ9xzsUxUhmky3gCd2KLxTXmpk4JKzhzP/tHKS5M y+pA== X-Gm-Message-State: APjAAAUr947vPamISAQIeDM9XWxnZhHo1r7uOuS6799kgcLPagg4+jD6 hy8O4Zulk1t+HRqU4yGzUJNOXzGFjaXo1nRmPQ3JGiva X-Received: by 2002:a9d:34c:: with SMTP id 70mr42778otv.174.1581462866714; Tue, 11 Feb 2020 15:14:26 -0800 (PST) MIME-Version: 1.0 References: <20200207201856.46070-1-bgeffon@google.com> In-Reply-To: <20200207201856.46070-1-bgeffon@google.com> From: Daniel Colascione Date: Tue, 11 Feb 2020 15:13:50 -0800 Message-ID: Subject: Re: [PATCH v4] mm: Add MREMAP_DONTUNMAP to mremap(). To: Brian Geffon Cc: Andrew Morton , "Michael S . Tsirkin" , Arnd Bergmann , linux-kernel , linux-mm , Linux API , Andy Lutomirski , Will Deacon , Andrea Arcangeli , Sonny Rao , Minchan Kim , Joel Fernandes , Yu Zhao , Jesse Barnes , Nathan Chancellor , Florian Weimer , "Kirill A . Shutemov" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 7, 2020 at 12:19 PM Brian Geffon wrote: > > When remapping an anonymous, private mapping, if MREMAP_DONTUNMAP is > set, the source mapping will not be removed. Instead it will be > cleared as if a brand new anonymous, private mapping had been created > atomically as part of the mremap() call. The left-behind mapping (the "as if a brand new anonymous, private mapping" map) is immediately writable, right? If so, we need to account the additional commit charge. What about making the left-behind mapping PROT_NONE? This way, we'll still solve the address-space race in Lokesh's use case (because even a PROT_NONE mapping reserves address space) but won't incur any additional commit until someone calls mprotect(PROT_WRITE) on the left-behind mapping. Imagine having two equal-sized mappings and wanting to use mremap() to swap them: you can implement this swap by carving off a third region of address space and making two mremap() calls. But without the PROT_NONE, you pay additional commit for that third region even if you don't need it.