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 B3F77C35655 for ; Fri, 21 Feb 2020 12:23:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 77F3224656 for ; Fri, 21 Feb 2020 12:23:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=shutemov-name.20150623.gappssmtp.com header.i=@shutemov-name.20150623.gappssmtp.com header.b="flaLEU0j" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 77F3224656 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E53096B0003; Fri, 21 Feb 2020 07:23:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E043F6B0006; Fri, 21 Feb 2020 07:23:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CF1DE6B0007; Fri, 21 Feb 2020 07:23:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0101.hostedemail.com [216.40.44.101]) by kanga.kvack.org (Postfix) with ESMTP id B55B66B0003 for ; Fri, 21 Feb 2020 07:23:20 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 64BC34DC2 for ; Fri, 21 Feb 2020 12:23:20 +0000 (UTC) X-FDA: 76514049360.01.nest19_745fd95a2c45f X-HE-Tag: nest19_745fd95a2c45f X-Filterd-Recvd-Size: 5648 Received: from mail-lf1-f66.google.com (mail-lf1-f66.google.com [209.85.167.66]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Fri, 21 Feb 2020 12:23:19 +0000 (UTC) Received: by mail-lf1-f66.google.com with SMTP id l18so1370959lfc.1 for ; Fri, 21 Feb 2020 04:23:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=TIZSxEqICxQETWAsSg7biuuXGcfw3yu6sTbolexyQEI=; b=flaLEU0j4Im4w/xAgm6LxaDp0XjnIlfbUObgsaisiu207aH8J5jPez1rm8Qudy6Xzm 68ObGcPxMMcPsa/EMVmYgm5kSB4MlfoTaMqZEE8v79Evn+ptOfwjwf7IDGNvwHZeLk0K 6YyP8GU4S+sgf/n/+/pNhHaGLbesRA9ZVTMxBGwRV3fHiW477pngUajYwK+XTNXCg4Ht cIq9/WZoxRR1jmTJEMT6RRzmsp3c6YFG7muwPsO+8LhdVQzzFC+DahrXC7wToarg01pj ZhJ00ojm54JcfVtAObfpIRjP3b+RvK5KylZsAFKhX8mKDkMoLYp05Gs7L/3ZyyxNLWzz paug== 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:message-id:references :mime-version:content-disposition:in-reply-to; bh=TIZSxEqICxQETWAsSg7biuuXGcfw3yu6sTbolexyQEI=; b=NKHG1HS9lJCsF46WCErj4t/XNs3qy8VbdzEFr0ktzGKF92Ua4XnXJI91uVqqjjCwG8 mfaYJrAHGnsKmH+mqbhWoLNFS83T/rL2rQjx9SEuIUNLlJGepfLgyZGzEEDAomkNyed8 lG5LNU80XaIBTULWtNUp0FtEvgZUizrHiziLtPYQTQ/692Ui7FGBnS0zifVD2cbmV30e hNKoS+DYm4R8AJpMqTZiI4hu23THN92gnt17hU/hrjby+bSZIeehhnQCxeeuQyB33gPA pN+QezBcDNs66PlbZmwkYhV/5EHy6/neOrSr9C9nxSgdkjV0O7txCdJTcZtJfiqD5m2B irbw== X-Gm-Message-State: APjAAAVsCAgNZKVygmAWSMwmIgJHXTUSshMoYaQlU0VAkBjxSgaIZu/d /klAWmGRw1GeIF3cOlg0Wt0+lw== X-Google-Smtp-Source: APXvYqwCGtBM1ilj7fS/22gI6FqN4kqqSRuZkmu/XAUS5IezK+0lNwoLD3chyi3De6oxVlnghDDoOQ== X-Received: by 2002:a19:6742:: with SMTP id e2mr19903630lfj.1.1582287798086; Fri, 21 Feb 2020 04:23:18 -0800 (PST) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id k24sm1862501ljj.27.2020.02.21.04.23.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Feb 2020 04:23:17 -0800 (PST) Received: by box.localdomain (Postfix, from userid 1000) id 3AE7B100FC3; Fri, 21 Feb 2020 15:23:47 +0300 (+03) Date: Fri, 21 Feb 2020 15:23:47 +0300 From: "Kirill A. Shutemov" To: Brian Geffon 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 Subject: Re: [PATCH v6 1/2] mm: Add MREMAP_DONTUNMAP to mremap(). Message-ID: <20200221122347.vlw6r7felchtcxgq@box> References: <20200218173221.237674-1-bgeffon@google.com> <20200220115744.ummq6j5ejp5qojic@box> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Thu, Feb 20, 2020 at 03:55:53PM -0800, Brian Geffon wrote: > 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. If anyone would want to chagne size it can be archived by followup mremap() operations. There's no need in one-shot operation. -- Kirill A. Shutemov