From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 106092 invoked by alias); 20 Feb 2018 01:04:00 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 105991 invoked by uid 89); 20 Feb 2018 01:03:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS,SPF_PASS,TVD_RCVD_IP autolearn=ham version=3.3.2 spammy=now, HContent-Transfer-Encoding:8bit X-HELO: glup.org Received: from 216-15-121-172.c3-0.smr-ubr2.sbo-smr.ma.static.cable.rcn.com (HELO glup.org) (216.15.121.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 20 Feb 2018 01:03:57 +0000 Received: from lister.boston.niksun.com (unknown [IPv6:2001:470:8bf0:2::1000]) by glup.org (Postfix) with ESMTPSA id A9F76854D8; Mon, 19 Feb 2018 20:03:55 -0500 (EST) Authentication-Results: glup.org; dmarc=none header.from=glup.org Subject: Re: Atomic mmap replacement To: cygwin@cygwin.com References: <66bf4f86-4618-b9a3-3e33-2c240b9204d0@cornell.edu> <20180219090042.GC3417@calimero.vinschen.de> <20180219171914.GA3619@calimero.vinschen.de> From: John Hood Message-ID: <3a317ca2-c4d7-d5e2-a93a-4756df9f9b57@glup.org> Date: Tue, 20 Feb 2018 01:04:00 -0000 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180219171914.GA3619@calimero.vinschen.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-SW-Source: 2018-02/txt/msg00217.txt.bz2 On 02/19/2018 12:19, Corinna Vinschen wrote: > On second thought, we *could* do this, if the pages have been mmapped > before(*). Unfortunately this would require a *major* revamp of the > page handling in mmap. We would have to keep the mapping of every > single 64K page separate. > > I.e., requesting a file mapping of 256K at offset 0 on the POSIX level > would have to be handled as four Windows file mappings under the hood: > > 1. a 64K file mapping at offset 0 > 2. a 64K file mapping at offset 65536 > 3. a 64K file mapping at offset 131072 > 4. a 64K file mapping at offset 196608 > > A request to mmap another 64K page to the third mapping in this example > could then be done by unmapping the third mapping and replace it with > the requested mapping. > > I'm not sure this is feasible. It would complicate and slow down the > code especially for big mappings; one call to NtCreateSection and one to > NtMapViewOfSection per 64K page, plus the overhead of making sure that > all mappings are in the right, sequential order in memory. Plus the > overhead of having to remap a lot more mappings in forked children. The > "Cygwin is slow" meme would get another interesting facet :} > I work on an app that does something like this (but for other reasons, and it'll never be ported to Cygwin). I'm also dubious, but I'll point out that it'd probably be reasonable to do this only on regions that are mapped PROT_NONE initially, other regions could work as they do now.  That'd help performance in the common case.  Also, if Windows has a way to prevent use of a region other than creating a mapping, Cygwin could perhaps emulate PROT_NONE mappings without actually creating a mapping (at the cost of even more code complexity, probably). regards,   --jh -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple