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.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, FSL_HELO_FAKE,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 3B720C11D19 for ; Thu, 20 Feb 2020 19:14:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EFC0F206E2 for ; Thu, 20 Feb 2020 19:14:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HeC+npsg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EFC0F206E2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 990866B0005; Thu, 20 Feb 2020 14:14:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9408C6B0006; Thu, 20 Feb 2020 14:14:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8578C6B0007; Thu, 20 Feb 2020 14:14:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0247.hostedemail.com [216.40.44.247]) by kanga.kvack.org (Postfix) with ESMTP id 6CFE16B0005 for ; Thu, 20 Feb 2020 14:14:37 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 2209A8248047 for ; Thu, 20 Feb 2020 19:14:37 +0000 (UTC) X-FDA: 76511456994.17.straw71_b29e36f27226 X-HE-Tag: straw71_b29e36f27226 X-Filterd-Recvd-Size: 5214 Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by imf26.hostedemail.com (Postfix) with ESMTP for ; Thu, 20 Feb 2020 19:14:36 +0000 (UTC) Received: by mail-pl1-f193.google.com with SMTP id a6so1928371plm.3 for ; Thu, 20 Feb 2020 11:14:36 -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=rVCC4ABYepOobW5p+17V0XD/W8tmsYbdwLWpJFplT2EWeR5cJDtdvhLN0pLk0GIfgV I1abAjEDneLYl8Tf9yA0TrgMAylApg0hNSxNi3SsDZf4RxO1tkslxLzHPbFPOuFeWmaX y5+NGz7gnJDj0ZZBabD0wxryacf7JNiYtiQN5B7ZgmLQolchqIA5d0xu5GX8VL5WuDpM Bv7FuH9j/Pzu2yvNa7JguDJlXKnx8QwyrtJz8sWTFAKyZg11+hzXrmAJIa2c28VRLftK EExqWxctP5t2rMGv2SpGHXfaf+XdyyMQ3uB1VJUlKEGEiOn+X3aKsptFjD03kyTe54vu INHQ== X-Gm-Message-State: APjAAAVs97UUmzLqKR+FVQ2xF2JNL919g6EyFVCDL60uw4jvVLPVsB/T npaYnw7W3bEXnaFxIP98d/I= X-Google-Smtp-Source: APXvYqw6y7Nhb4vjA5yJoK8XclQcAOEQlx4Y0ZxOWmGiku8xlJ6tQ7PMUsOzidtgo3Q+t0gDUVPNCQ== 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) 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 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!