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=-8.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 06615C11D19 for ; Thu, 20 Feb 2020 18:46:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B4BF824673 for ; Thu, 20 Feb 2020 18:46:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="t/iabB7z" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B4BF824673 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 622816B000A; Thu, 20 Feb 2020 13:46:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5D1FC6B000C; Thu, 20 Feb 2020 13:46:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4E8006B000D; Thu, 20 Feb 2020 13:46:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0096.hostedemail.com [216.40.44.96]) by kanga.kvack.org (Postfix) with ESMTP id 37DB26B000A for ; Thu, 20 Feb 2020 13:46:13 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id DF0A44DA3 for ; Thu, 20 Feb 2020 18:46:12 +0000 (UTC) X-FDA: 76511385384.29.kitty96_3634601d1d563 X-HE-Tag: kitty96_3634601d1d563 X-Filterd-Recvd-Size: 5018 Received: from mail-ed1-f68.google.com (mail-ed1-f68.google.com [209.85.208.68]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Thu, 20 Feb 2020 18:46:12 +0000 (UTC) Received: by mail-ed1-f68.google.com with SMTP id c7so2868129edu.2 for ; Thu, 20 Feb 2020 10:46:12 -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=3pzTOf6vYrNpBzwrv5P8vGUEMGl4yTghrNTGfR5M7Oc=; b=t/iabB7zJkaoluyOjIOJfc2zOAmtCMc0F/y/TF2fj7jW83AkZqMCidXI1cWAbd1seh NrPIkCTa7wgPP3M5+5W4Nd8wCviO86LJDU/66mUTKdZUNRZSGcNC+WNlPLabRaKp4SR+ orsRRi/sfSaMIAGI3SoDi7MDtWF06zukVhMxyMS8/yfYakd+jGja2CyT12U5oXkmI8sN z5jMtx62wuJh4j4W5bIO2P70wW6bBQ278/BBWp++v1TyluKJlkdg9fCLT1VNOntUyF2q Dp4wBg6EPgY/049JRWKGl3hU5FeH12hRn285BsTec8q28s4O1DhJH6apj0UVzQYbrXgZ AeHA== 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=3pzTOf6vYrNpBzwrv5P8vGUEMGl4yTghrNTGfR5M7Oc=; b=Elf7w2F/eK9jsOjU6kXJeSQ/ASVWGZzV/WLT9uFCr5gVUc8tpIUs9v2qmlcbT/Kssy YOBdcMmGT5xejvl4GcxrE14Lu53BqKa9YpRMrklU1I9Yx9eIrZIqzA02SdVQkBPTh7si 42nojEpAnPouD/nP7AmH5MBd1CmusVJ7vEREgnbwyZBEcmeUUPUnEUsdMgYlRIGhMlhB MzgDu5N8AuJZidoxOTFrEGF+vi5D07p3ZMxt4oWAyiMYffeAYD/ManwsLvpxaVWRNm3G FtqFL4csDHgD6u7fibgGXcM1U5jsx4QkUsNYVlHlY4M/CSqlqBKFQB3GJA4QIdlTyraZ LtWA== X-Gm-Message-State: APjAAAUhKbEKw3pKjl8Jp+h3w0KEXyQW7aWpHleYQKsH33BFqbn8kx/6 6I1JXCAC4/1+U/NGNzJEr+kbA5mGJ1IRaW8ekxDTGg== X-Google-Smtp-Source: APXvYqxLLjMlzm9n1gTBdsGBP2Dd4mIMoNz+RxUJ/scsjYrcKm8cv5eKltlsAg/aIqFp91+eAChxVZYEb3UQBPTKYf4= X-Received: by 2002:a17:906:1e48:: with SMTP id i8mr28875694ejj.189.1582224370598; Thu, 20 Feb 2020 10:46:10 -0800 (PST) MIME-Version: 1.0 References: <20200218173221.237674-1-bgeffon@google.com> <20200220171554.GA44866@google.com> In-Reply-To: From: Brian Geffon Date: Thu, 20 Feb 2020 10:45:44 -0800 Message-ID: Subject: Re: [PATCH v6 1/2] mm: Add MREMAP_DONTUNMAP to mremap(). To: Minchan Kim 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" Content-Type: text/plain; charset="UTF-8" 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: Sorry I should clarify that this is the behavior with MREMAP_FIXED is used, and to expand on that, it would potentially even have unmapped the region at the destination address and then fail in vma_to_resize too, so I hope that explains why that check landed there. But should these situations be considered a bug? Brian On Thu, Feb 20, 2020 at 10:36 AM 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. > > 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? > > Thank you for taking the time to review. > > Brian