Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752516AbdGGRMt (ORCPT ); Fri, 7 Jul 2017 13:12:49 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:27215 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751100AbdGGRMr (ORCPT ); Fri, 7 Jul 2017 13:12:47 -0400 Subject: Re: [RFC PATCH 0/1] mm/mremap: add MREMAP_MIRROR flag To: Anshuman Khandual , linux-mm@kvack.org, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org References: <1499357846-7481-1-git-send-email-mike.kravetz@oracle.com> <0f935c5a-2580-c95a-4ea5-c25e796dad03@linux.vnet.ibm.com> Cc: Andrew Morton , Andrea Arcangeli , Michal Hocko , Aaron Lu , "Kirill A . Shutemov" From: Mike Kravetz Message-ID: <7a5d293b-44d7-b0f4-20e5-6a3428c25ed2@oracle.com> Date: Fri, 7 Jul 2017 10:12:32 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <0f935c5a-2580-c95a-4ea5-c25e796dad03@linux.vnet.ibm.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Source-IP: aserv0022.oracle.com [141.146.126.234] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1626 Lines: 31 On 07/07/2017 04:03 AM, Anshuman Khandual wrote: > On 07/06/2017 09:47 PM, Mike Kravetz wrote: >> The mremap system call has the ability to 'mirror' parts of an existing >> mapping. To do so, it creates a new mapping that maps the same pages as >> the original mapping, just at a different virtual address. This >> functionality has existed since at least the 2.6 kernel [1]. A comment >> was added to the code to help preserve this feature. > > In mremap() implementation move_vma() attempts to do do_unmap() after > move_page_tables(). do_unmap() on the original VMA bails out because > the requested length being 0. Hence both the original VMA and the new > VMA remains after the page table migration. Seems like this whole > mirror function is by coincidence or it has been designed that way ? I honestly do not know. From what I can tell, the functionality existed in 2.4. The email thread [1], exists because it was 'accidentally' removed in 2.6. All of this is before git history (and my involvement). My 'guess' is that this functionality was created by coincidence. Someone noticed it and took advantage of it. When it was removed, their code broke. The code was 'fixed' and a comment was added to the code in an attempt to prevent removing the functionality in the future. Again, this is speculation as I was not originally involved. The point of this RFC is to consider adding the functionality to the API. If we are carrying the functionality in the code, we should at least document so that application programmers can take advantage of it. [1] https://lkml.org/lkml/2004/1/12/260 -- Mike Kravetz