allow read into untouched noreserve mappings

Corinna Vinschen corinna-cygwin@cygwin.com
Tue Jul 18 14:07:00 GMT 2006


On Jul 17 17:54, Brian Ford wrote:
> Untested this time because I have to run to an appointment.
> 
> 2006-07-17  Brian Ford  <Brian.Ford@FlightSafety.com>
> 
> 	* winsup.h (mmap_region_status): New enum.
> 	(mmap_is_attached_or_noreserve_page): Adjust prototype and rename
> 	as below.
> 	* mmap.cc (mmap_is_attached_or_noreserve_page):  Rename
> 	mmap_is_attached_or_noreserve.  Add region length parameter.
> 	Return enum above.
> 	* exceptions.cc (_cygtls::handle_exceptions): Accomodate above.
> 	* fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS
> 	errors and retry on success to allow reads into untouched
> 	MAP_NORESERVE buffers.

I applied your patch to the cv-branch with some changes.  The way you
are calling search_record (see there)

> +      long record_idx = map_list->search_record ((caddr_t)addr, 1,
> +						 u_addr, u_len, -1);

always returns a u_len of 1. The result is that for each page in memory,
the loop runs 4096 times in the worst case.  I added the necessary
alignment stuff and minimized the number of calls to VirtualAlloc.

Don't be surprised that I now used getpagesize() instead of
getsystempagesize ().  I mulled over this a while.  The idea is that the
application expects a page size of 64K, not 4K.  So the functionality
makes most sense if it assumes 64K pages, too.  This also minimizes the
number of necessary calls to mmap_is_attached_or_noreserve_page, which
is a good thing, IMO.

Thanks for the patch.  It's available for further digestion and patches
in the cv-branch.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat



More information about the Cygwin-patches mailing list