Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1226962ybv; Thu, 20 Feb 2020 15:56:44 -0800 (PST) X-Google-Smtp-Source: APXvYqzQ8+Y/rLKXHnjj//ejVWTN4rcH9KvY1hCMHnJAgiFmOd8ouLTTAUnuF5o0mE4mp72VubsZ X-Received: by 2002:aca:fcd4:: with SMTP id a203mr3836682oii.167.1582243004457; Thu, 20 Feb 2020 15:56:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582243004; cv=none; d=google.com; s=arc-20160816; b=v+RJTi5jNLV6GNcO33jPec4aKJ/Hw9WCjR4hXI14TzU8mcCE7O/n47zRvSzkg80Vpu /XxDvHXGl3L5pldQWThSVMN38RhYuQy/dKCC/7GVu/T1WG0jcmcj0i8AMD7E4NEd15oR Pqkkn+taZGWHH3my2Bxe+chMeZK0mz5UT5Igvote0EamMaYHTVjVxBBJKLNIFAbBB2WI Rn3CyFrrEQpm51dFcVtwF4UwlaEiwSTu66fDj/URXFfbciDJULSSuc4SnCntZwMp3kKK dOv4bkG8HJBB8Z9R0R43zouAEqoWP67mhk1PU6tKIWf97RnBMzsrBkNB1UKdolx1bo19 B1Iw== 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=NNDEYAC7DB9YZj2gZI9Z6zcgcjYXY0WlNUd/lj4aAPs=; b=mAJrzChs42Cpex74mpy8tvQ6gKut9O/u8npBIeBcC2kKRVj5LbPj9j1iyWKRaGd2uJ DwSyoKoVIDL5j4BnfgSrRY0qQssYh+UQtUEL72nHv7S1S3ZE9BRCAWUCaHUCQ7XZQavJ QSEewH/TGLfzDX4WBqyJGCx11uY+FIbVhaMJtDUTWTypqSjk9Dqg+FesdYRfVSf9lYaX hV/mtPEohEtDQ+PB/Hh4SEVE4jS1ybD6PtWE4PGxcU8B3ddO7KFPd1uhWEMrz175CvyS e+zKbUzJ+EeV3K6lS6AB9wSwejofIwCJnlgJXMKBTg/CbFHN+gxpTmvlICRmbesfymbZ THkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=XXGyT2OT; 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 l65si443675oih.23.2020.02.20.15.56.29; Thu, 20 Feb 2020 15:56:44 -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=XXGyT2OT; 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 S1729365AbgBTX4W (ORCPT + 99 others); Thu, 20 Feb 2020 18:56:22 -0500 Received: from mail-ed1-f67.google.com ([209.85.208.67]:43362 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729295AbgBTX4W (ORCPT ); Thu, 20 Feb 2020 18:56:22 -0500 Received: by mail-ed1-f67.google.com with SMTP id dc19so143281edb.10 for ; Thu, 20 Feb 2020 15:56:21 -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=NNDEYAC7DB9YZj2gZI9Z6zcgcjYXY0WlNUd/lj4aAPs=; b=XXGyT2OTWpB64th/vPVkrN8ruW2f9cZk6TbylbolgAVKvklROGPImgdexYcm7PLy+f BQTWWPL1F3qIN7l3Dq0t9Uu68LaVEjTVVH3auFqU7GxZPXIvpkmrC16+4Z1H1cJOebL5 Lvo1QJHLtGwmVRsdCOiaMRq4DYeqlDXcfrVJdD7R2pwkOZREAbrYu4uO69FSE1NQjX41 LHAhCWZNeW5WU9pBAp27tB02+HKXN20P76igbJaaQi0x/nItXf1MM5UocyVhxVMtvBJ3 ayy3sAy5iev4TWkVL/NJTUQfH2mnlc/NEqADgydaiOsyVsK7eC5LwvaXHBbFhtT3g4wp 4ivQ== 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=NNDEYAC7DB9YZj2gZI9Z6zcgcjYXY0WlNUd/lj4aAPs=; b=Y2OQIKQZIPn5UIH7DUxNwp3gBe91/XXGTM3RYJxuIkgXp2kYN5oPptHJ62RD7lq4eT ZmUb2urHK5xlCwvONSLPFbQyg/Q0sINGO7nGNyQzA9M59k1Jr0r5jEXr4RM/v8TJzCDc n4JY9fRotJ2FInDbfzWot+WI/nVu18V8vMDPrlCX/LsqT4pyi03k7VVTS4hJQUy4OtGr suamiaULPyvZboSMMCTfuGYY6FTpiJYvAfgEr+zVG0uvL8+KSmvmxcfMcf59AaigcNyl 2QQXuTl5Eh/pvaV89ngIcBeY8/UGfpRYoQGdko/7wTmfRkTg0d2zSGIIpS40K6V4Biur 1nbA== X-Gm-Message-State: APjAAAUnNCl7DZn8MTNVqdBgEG31xdvg5OeoixD/by5gHYc6NMgjpkQO BJ1n2rpSxJmgASc+mSBkE+VY7NIUGg1PtovM1tdmDg== X-Received: by 2002:a05:6402:6c7:: with SMTP id n7mr30390013edy.177.1582242980107; Thu, 20 Feb 2020 15:56:20 -0800 (PST) MIME-Version: 1.0 References: <20200218173221.237674-1-bgeffon@google.com> <20200220115744.ummq6j5ejp5qojic@box> In-Reply-To: <20200220115744.ummq6j5ejp5qojic@box> From: Brian Geffon Date: Thu, 20 Feb 2020 15:55:53 -0800 Message-ID: Subject: Re: [PATCH v6 1/2] mm: Add MREMAP_DONTUNMAP to mremap(). To: "Kirill A. Shutemov" Cc: Andrew Morton , "Michael S . Tsirkin" , Arnd Bergmann , LKML , linux-mm , Linux API , Andy Lutomirski , Will Deacon , Andrea Arcangeli , Sonny Rao , Minchan Kim , Joel Fernandes , Yu Zhao , Jesse Barnes , Florian Weimer 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 Kirill, > I have hard time understanding the case when new_len != old_len. > > Correct me if I'm wrong, but looks like that you change the size of old > mapping to be the new_len and then create a new of the same new_len. > > This doesn't look right to me. > > In my opinion, MREMAP_DONTUNMAP has to leave the old mapping intact. And > create the new mapping adjusted to the new_len. > > Other option is to force new_len == old_len if MREMAP_DONTUNMAP is > specified. It would simplify the implementation. And I don't see why > anybody would really want anything else. I had been approaching this as, "do what mremap would have done in this situation except skip the last step." Meaning, whatever the final state of the old mapping was MREMAP_DONTUNMAP meant that you should just not do the unmap operation on the old mapping at the end. But I understand why it's confusing, especially when in the case of the VMA growing you're left with the old vma of size old_len and the new_vma of size new_len but only containing old_len worth of pages. Personally, I don't think this is a problem having that behavior because it can be documented and it just adds a small amount of flexibility. Nonetheless, I agree with you and I also cannot come up with a situation where you'd actually want to do this so I'm willing to restrict it to old_len == new_len and return -EINVAL if not, it simplifies it a bit and accounting becomes a easier because the outcome is always the same two mappings of size old_len and the size of the locked_vm never changes. We can always allow the resize operation later if there becomes a need. If everyone is okay with this restriction I can send a new patch. Thank you again, Brian