Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5420378ybv; Tue, 11 Feb 2020 15:34:22 -0800 (PST) X-Google-Smtp-Source: APXvYqwL2ZZTpviupIKjHKgzgs2VOAnZByr5IPofOao/GlAXLQD9KPKZYYtwqYYkpPu+1qbFk5Hg X-Received: by 2002:aca:f44a:: with SMTP id s71mr4468676oih.7.1581464062072; Tue, 11 Feb 2020 15:34:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581464062; cv=none; d=google.com; s=arc-20160816; b=CMVC+mCMoHaAz6iekZbuGX25ClhtA5MsTvULEMqb/LIdAwGp9dYNw7i5Yv9pr2JOzN eL3L5XA+lrPpO1Fton5Ff/miVRLjLw8O7E0wSTi0VLu1oT+tVflgSk+uuPyw82DnjwqD z5gZJVsq3U/Q9RXUQCQhpYV0ZtSwdsd5i4ODRokXx0WHyl+0AIK9hGsJNTBLuFOwzIyf wYSoO4ksay2nAX8O2AVKJ+3FDGWySBGsi7rU93EnuCk6N66TwUl8GFfEIvvA0eD+h0If MH/31eEYyfBiCsovhwSxzoucY6ok4O5vX9gfS7liitmQUEJ3+lY0RnF/PGybLZ4p8c0V ESEA== 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=dSs7UqmD5JkZZbHb6Da5Z4JrHfZRP5ftJHQt9uAAdrI=; b=gaKQ9uo2yhXZwiUxfujDG1phLxGyulIIV7NIAkmqpTxDmLmD8YSVISyvZVz+MgSJ4L ZxRwIKj4uUGcVYUubmhLpn7nLbU4qc7d6g7IePHnSLdMDBSZSvq54aWOZEXRqQTvh8W1 dwQOreUQ9evjcMLvxjyNioOHwKTpaWEb6Z9XJgHTYOOOxf2DNw6WbK1czMdus8d3PMTZ 90hSRep3YrD/88CAxv4PEPVxIG7vl07r9HyaK7D9dnSmco9zKqVqGJZVTBSIUnLx0hCT dLw3SN3ochbE8CE6AssGo9024DqJMgGbO3rQyHcezC8l1fDgLyIXQhuNKcifLVL17PV6 gOYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=liMR+ja4; 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 b18si2678518otp.17.2020.02.11.15.34.09; Tue, 11 Feb 2020 15:34:22 -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=liMR+ja4; 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 S1727933AbgBKXcz (ORCPT + 99 others); Tue, 11 Feb 2020 18:32:55 -0500 Received: from mail-ed1-f67.google.com ([209.85.208.67]:42957 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727847AbgBKXcz (ORCPT ); Tue, 11 Feb 2020 18:32:55 -0500 Received: by mail-ed1-f67.google.com with SMTP id e10so160860edv.9 for ; Tue, 11 Feb 2020 15:32:53 -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=dSs7UqmD5JkZZbHb6Da5Z4JrHfZRP5ftJHQt9uAAdrI=; b=liMR+ja4NzU1aOeqaKl4lbrBoRPtK+iwhpCD3ABdyNXC3IV0OkN3hWEOnv+stwyz0p dLvQVDNXNtPDaA4s61UCJ/3rotRJB/rTr5S8Cf9nj7ULYw81Aw4eW6jcW8FSnkpmkvFd S6jaIPrwapXw4jFnQN3EKyucf6zFOyc2+AAVH3ZF+KkhnTYbaAZHf9l69KVrBBOME6gy /mUhEwIhyx2yeczYKS/Ts9DFICgi9MWfVd6V5YiEbXZNoeczIP9qwGVwnFrqIrj7UhGM TlJlsGQhF7vrtBEFZYIULny/TaQZIx8x7GxfyVcNWvMGsS/sfcOBKF4lPCrnZ6HS/y0D dGCQ== 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=dSs7UqmD5JkZZbHb6Da5Z4JrHfZRP5ftJHQt9uAAdrI=; b=qemQevKL3jCIaPV+TfXvbo5FOJ84O+E5TQ4l9nv28de6rxnymk85DcdCnT0z+qYTPh X6MDUp/WitbKJ3v/O19DcEtCVBTS7Hgzanw+qPy0z/cXwjQbG1Gm1DXXEmb1J7DU/0b6 HReRpqG961EYDfYqgLD4r3tHqQi48C0tHomtFyMHPl24ZcdY+t157CIqEJhRujQByr6a I50jYAPyNhpTCM/1Ac4w/oUjqfe2bU/LUgxAxy8wriMTeo25W7ANHUkMsM3rcNKXgqho mojBxGBMaLLqAlF8oML3j2ficcHPrMQ/X089kISHW8XGXhLEdWGjNywTcz/y3HKP0DwX 4+Uw== X-Gm-Message-State: APjAAAXnhUJxN5+DEyxgHJxtuU5hTQD4y2T8DaTr2T9c6zjcZ9zUc0/v HN9JHGeyX9MBEtpkvW8Hp8BqD9zGEuI8OU2EO1Bb4w== X-Received: by 2002:a05:6402:6c7:: with SMTP id n7mr7881480edy.177.1581463973027; Tue, 11 Feb 2020 15:32:53 -0800 (PST) MIME-Version: 1.0 References: <20200207201856.46070-1-bgeffon@google.com> In-Reply-To: From: Brian Geffon Date: Tue, 11 Feb 2020 15:32:26 -0800 Message-ID: Subject: Re: [PATCH v4] mm: Add MREMAP_DONTUNMAP to mremap(). To: Daniel Colascione 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 Hi Daniel, > 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. This limits the usefulness of the feature IMO and really is too specific to that one use case, suppose you want to snapshot a memory region to disk without having to stop a thread you can mremap(MREMAP_DONTUNMAP) it to another location and safely write it to disk knowing the faulting thread will be stopped and you can handle it later if it was registered with userfaultfd, if we were to also change it to PROT_NONE that thread would see a SEGV. There are other examples where you can possibly use this flag instead of VM_UFFD_WP, but changing the protections of the mapping prevents you from being able to do this without a funny signal handler dance. Brian