Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935355AbdIYMkt (ORCPT ); Mon, 25 Sep 2017 08:40:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52848 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933476AbdIYMkq (ORCPT ); Mon, 25 Sep 2017 08:40:46 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3328668B8 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=fweimer@redhat.com Subject: Re: [patch] mremap.2: Add description of old_size == 0 functionality To: Michal Hocko Cc: Mike Kravetz , mtk.manpages@gmail.com, linux-man@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Andrea Arcangeli , "Kirill A . Shutemov" , Vlastimil Babka , Anshuman Khandual , linux-mm@kvack.org References: <20170915213745.6821-1-mike.kravetz@oracle.com> <20170925123508.pzjbe7wgwagnr5li@dhcp22.suse.cz> From: Florian Weimer Message-ID: Date: Mon, 25 Sep 2017 14:40:42 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20170925123508.pzjbe7wgwagnr5li@dhcp22.suse.cz> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 25 Sep 2017 12:40:46 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1186 Lines: 26 On 09/25/2017 02:35 PM, Michal Hocko wrote: > What would be the usecase. I mean why don't you simply create a new > mapping by a plain mmap when you have no guarantee about the same > content? I plan to use it for creating an unbounded number of callback thunks at run time, from a single set of pages in libc.so, in case we need this functionality. The idea is to duplicate existing position-independent machine code in libc.so, prefixed by a data mapping which controls its behavior. Each data/code combination would only give us a fixed number of thunks, so we'd need to create a new mapping to increase the total number. Instead, we could re-map the code from the executable in disk, but not if chroot has been called or glibc has been updated on disk. Creating an alias mapping does not have these problems. Another application (but that's for anonymous memory) would be to duplicate class metadata in a Java-style VM, so that you can use bits in the class pointer in each Java object (which is similar to the vtable pointer in C++) for the garbage collector, without having to mask it when accessing the class metadata in regular (mutator) code. Thanks, Florian