delorie.com/archives/browse.cgi | search |
DMARC-Filter: | OpenDMARC Filter v1.4.2 delorie.com 4BHGd2iq044717 |
Authentication-Results: | delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com |
Authentication-Results: | delorie.com; spf=pass smtp.mailfrom=cygwin.com |
DKIM-Filter: | OpenDKIM Filter v2.11.0 delorie.com 4BHGd2iq044717 |
Authentication-Results: | delorie.com; |
dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=yG1NjRne | |
X-Recipient: | archive-cygwin AT delorie DOT com |
DKIM-Filter: | OpenDKIM Filter v2.11.0 sourceware.org 1BB8F3858C41 |
DKIM-Signature: | v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; |
s=default; t=1734453540; | |
bh=aK0KJRd26YQEYF+AAoMD0ccsLZoVPvJe1KVyARvagA8=; | |
h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: | |
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: | |
From; | |
b=yG1NjRneWblxU+Hw6K4Dg8ciIxkisG7qlSQoDANUsnj4vSC1XX7xbXEJpHFd87dQe | |
OwYg7D+KlB25L4yk5suE7VRpJBO/KK5xzFr/T8jWFXKuwJ/IP29a1ttNxr2N116zj3 | |
QzYKd58xCOHtCNgUHTTtfC8YVh4Djkm+DQDwVN8A= | |
X-Original-To: | cygwin AT cygwin DOT com |
Delivered-To: | cygwin AT cygwin DOT com |
DKIM-Filter: | OpenDKIM Filter v2.11.0 sourceware.org 13D5E3858D1E |
Date: | Tue, 17 Dec 2024 17:38:35 +0100 |
To: | cygwin AT cygwin DOT com |
Subject: | Re: Atomic mmap replacement |
Message-ID: | <Z2GpCxIUDMqp6yen@calimero.vinschen.de> |
Mail-Followup-To: | cygwin AT cygwin DOT com |
References: | <66bf4f86-4618-b9a3-3e33-2c240b9204d0 AT cornell DOT edu> |
<20180219090042 DOT GC3417 AT calimero DOT vinschen DOT de> | |
<e6b3bd42-f981-405e-b65b-529693598735 AT cornell DOT edu> | |
<d84f7f6c-5527-4f39-83a5-1aa16d8e451f AT cornell DOT edu> | |
<Z2AsCg7Oo4FyHFjG AT calimero DOT vinschen DOT de> | |
<b7564609-6a87-4691-b5ec-1f56b51543df AT cornell DOT edu> | |
<bb796c13-c2b7-48a0-899b-cc7485fee783 AT cornell DOT edu> | |
MIME-Version: | 1.0 |
In-Reply-To: | <bb796c13-c2b7-48a0-899b-cc7485fee783@cornell.edu> |
X-BeenThere: | cygwin AT cygwin DOT com |
X-Mailman-Version: | 2.1.30 |
List-Id: | General Cygwin discussions and problem reports <cygwin.cygwin.com> |
List-Unsubscribe: | <https://cygwin.com/mailman/options/cygwin>, |
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe> | |
List-Archive: | <https://cygwin.com/pipermail/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-request AT cygwin DOT com?subject=help> |
List-Subscribe: | <https://cygwin.com/mailman/listinfo/cygwin>, |
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe> | |
From: | Corinna Vinschen via Cygwin <cygwin AT cygwin DOT com> |
Reply-To: | cygwin AT cygwin DOT com |
Cc: | Corinna Vinschen <corinna-cygwin AT cygwin DOT com> |
Errors-To: | cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com |
Sender: | "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com> |
X-MIME-Autoconverted: | from base64 to 8bit by delorie.com id 4BHGd2iq044717 |
Hi Ken, On Dec 17 10:34, Ken Brown via Cygwin wrote: > On 12/16/2024 2:58 PM, Ken Brown via Cygwin wrote: > > On 12/16/2024 8:32 AM, Corinna Vinschen via Cygwin wrote: > > > Right now, mmaping with PROT_NONE and then re-mmaping with PROT_WRITE > > > doesn't work. Cygwin implements PROT_NONE not as MAP_RESERVE, but as > > > MEM_COMMIT with PAGE_NOACCESS. mmap() doesn't check if the requested > > > pages are already allocated with PAGE_NOACCESS and then succeeds while > > > in fact just changing the page protection. This is basically what > > > you want. Right now, you'd have to call mprotect() instead. > > > > > > With anonymous mappings only, this is all just adding a bit of code to > > > mmap() to do what mprotect() does in this case. > > > > [...] > > > > > So only anonymous mappings would be possible, assuming we tweak mmap() > > > to check if the old mapping was anonymous either and then allow to > > > just change the page protection, as if mprotect has been called. > > > > > > And, funny enough, something pretty similar already exists in mmap(). > > > See mmap.cc, line 1051 and the mmap_list::try_map() method. Right > > > now it only checks if an anonymous mapping has been partially unmapped > > > and can be recycled. But it could be improved by allowing to recycle > > > the anonymous mapping either way, as long as the new mapping is also > > > anonymous and the SHARED/PRIVATE flags match. > > Thanks! This looks doable. I hope to get back to you with a patch in > > the not-too-distant future. > While looking at this, I came across a bug in the use of > mmap_list::try_map(): On success, the recycled pages are given the same > protection they had as part of the original mmap_record instead of the > protection requested in the mmap call. This is done in > mmap_record::map_pages. Thanks for catching! > Would you like a separate patch to fix this, or should I just fix it as part > of the bigger project? Ideally a separate patch. If you see a chance to send it to cygwin-patches this week, we can even merge it into 3.5.5, which I'm planning to release end of this week (after that --> vacation :))) Thanks, Corinna -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |