Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1005365ybv; Thu, 20 Feb 2020 11:16:16 -0800 (PST) X-Google-Smtp-Source: APXvYqzJ0g/01vVoX8+6A/oazJ/Q0uK1HjVoi6ZBj25K/lefGIbITuoVpgjCGssORg9SZxyycjSn X-Received: by 2002:a05:6830:12d5:: with SMTP id a21mr25656987otq.296.1582226176209; Thu, 20 Feb 2020 11:16:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582226176; cv=none; d=google.com; s=arc-20160816; b=wVC/b+J7g1fb0lTj0xheiieVR4WoxRTi6hnFf6zJqlRqJAOCq6CEzn5snk0TA5eC0i DmtcoSniDXIx5BiK6NgvdpCk7CxQjQnO7P08+o5LPDi2qVBKfKI2uLXXnRf82Bb7VY56 gm/QbLbPuFVuIng0CfmC69xQoV7Fv3WcaifxzkqWVgl1KYBdwi1l24ERkO8jcB+xCkw+ 8C5+c+O2gMBfdiOKXtugNzlCRwyWk7UTvxYg/6drFoB/rVq26jwnjYf6EXQbZnUgj20D mojdS9VloUS5EY3DnTWfYeEl56xdrs3qe/exKu7VV6kwsFE2m53SYnpIDe6SkCxvCQGd jvPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=h9IQQUeC9EperJkziFiFFU+AHHaFbtQiLn6EJLG6aXI=; b=Kou1BhCXMRvlKKVlv1RMTxc35+fhZpTp4rE8D8Ak08eXZTf9U46t94cYj9eEbf1HkE ALOFBUVO6SIkwf9lh0/1Bkl4381DhF/EEyZCe9Xzmut5IJyL2M9ZguR6QiJ5AGCiE1we QoUhHhzg+yKCRHWJNhB32jxRxqiN536JoB/Qa+LilRxYyUvUdEDWGzEuceS6j+cN1o/q sU6nrK//8pkviz6iAsjsidedxpEw68ETtUy3TQAJqntF9sKxQjgH/xFCKJDtohj47Po+ kZ077bxKErUDUxaEggaAS5GfrYnec6bThL/eOrjOq5W9md1DZdJR3Z2uulf0jzLmPpat CZlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=HeC+npsg; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v26si193547otj.0.2020.02.20.11.16.02; Thu, 20 Feb 2020 11:16:16 -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=fail header.i=@gmail.com header.s=20161025 header.b=HeC+npsg; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728865AbgBTTOg (ORCPT + 99 others); Thu, 20 Feb 2020 14:14:36 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:43250 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728111AbgBTTOg (ORCPT ); Thu, 20 Feb 2020 14:14:36 -0500 Received: by mail-pl1-f195.google.com with SMTP id p11so1909330plq.10; Thu, 20 Feb 2020 11:14:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=h9IQQUeC9EperJkziFiFFU+AHHaFbtQiLn6EJLG6aXI=; b=HeC+npsgBHhiJ8NIcu/dVdd2oXGRPJ3NFOC7+E5vznBVbARU0WycUTo4gFBmcRqweo GGrURpmF8J/wkrAvK2EfiBwBxqSTjnaXP3tQ1y0+vAsIfeDnwCb1zFqZYdBjNj+K2D8z OwFNPf7m+ieszSqmoZWnTXSAyJHL0lri8Cvpp9iwtx5PvW8HhrT2I+bR+es09KZjGqEV 4ZA+k7LU5x9V6oq8AZrTI2UzpoQRi8u2lDW6Dz7syIto31tj6co6nyssRfFvNw/BMcCj 0cxx2fzSVeVRE8/sKDNVZuUTNPWW/LW4AhPTwY33l0L3snhpHpevqTwNIaDfmZRwO1PX 7xjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=h9IQQUeC9EperJkziFiFFU+AHHaFbtQiLn6EJLG6aXI=; b=R03CUQiYFYIKD19Bvtgs224cfJsCpoH/ndTbd/XqzOH8Sn4cCXilGkb8TAAI+m+hfL qT0gFzfu0a3y0b+gBMKR0J4DvDs5MDf00hun47ohze0UHBj1NF6EFbTFSqj0QZr9Zypp 9wOQf5WG5hOWRpbGa0ueShnTSZRPUVmbbPgBhNp9iOjQM8ogbLxGh/w6UwIsu+mrkVKy ea6UoVuLspLkB4qJtmQ0VtEOWU3p2fhzLL6su9gwdwKFvUHEhPNdhx7Hklanpbm/3F0C izKb3EHakoEYzNSS3LR8/k2zNYx8582YGjzC/6FiuU9eLYfkaHWlyj7jin9E2v2vouwS 8Z8A== X-Gm-Message-State: APjAAAXko2uGcfFvBOW2EUJd6qnLcCBysgseuFB1i77Ap0hIwyFpMPBu BxgWU3B/Xqs6r1csnak/7jg= X-Received: by 2002:a17:90a:1f8d:: with SMTP id x13mr5471397pja.27.1582226075283; Thu, 20 Feb 2020 11:14:35 -0800 (PST) Received: from google.com ([2620:15c:211:1:3e01:2939:5992:52da]) by smtp.gmail.com with ESMTPSA id z5sm375930pfq.3.2020.02.20.11.14.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Feb 2020 11:14:34 -0800 (PST) Date: Thu, 20 Feb 2020 11:14:32 -0800 From: Minchan Kim To: Brian Geffon Cc: Andrew Morton , "Michael S . Tsirkin" , Arnd Bergmann , LKML , linux-mm , Linux API , Andy Lutomirski , Will Deacon , Andrea Arcangeli , Sonny Rao , Joel Fernandes , Yu Zhao , Jesse Barnes , Florian Weimer , "Kirill A . Shutemov" Subject: Re: [PATCH v6 1/2] mm: Add MREMAP_DONTUNMAP to mremap(). Message-ID: <20200220191432.GA180571@google.com> References: <20200218173221.237674-1-bgeffon@google.com> <20200220171554.GA44866@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 20, 2020 at 10:36:38AM -0800, Brian Geffon wrote: > Hi Minchan, > > > And here we got error if the addr is in non-anonymous-private vma so the > > syscall will fail but old vma is gone? I guess it's not your intention? > > This is exactly what happens today in several situations, because > vma_to_resize is called unconditionally. For example if the old vma > has VM_HUGETLB and old_len < new_len it would have unmapped a portion > and then in vma_to_resize returned -EINVAL, similarly when old_len = 0 > with a non-sharable mapping it will have called do_munmap only to fail > in vma_to_resize, if the vma has VM_DONTEXPAND set and you shrink the > size with old_len < new_len it would return -EFAULT after having done > the unmap on the decreased portion. So I followed the pattern to keep > the change simple and maintain consistency with existing behavior. Fair enough. It seems to be very old existing behavior but man page never mention about it. :( > > But with that being said, Kirill made the point that resizing a VMA > while also using MREMAP_DONTUNMAP doesn't have any clear use case and > I agree with that, I'm unable to think of a situation where you'd want > to resize a VMA and use MREMAP_DONTUNMAP. So I'm tempted to mail a new > version which returns -EINVAL if old_len != new_len that would resolve > this concern here as nothing would be unmapped ever at the old > position add it would clean up the change to very few lines of code. > > What do you think? Agreed. That makes code more simple/clean. Thanks!