Subject: Re: CVS commit: src/usr.bin/cmp
To: David Laight <david@l8s.co.uk>
From: Chuck Silvers <chuq@chuq.com>
List: source-changes
Date: 02/07/2005 07:58:19
On Mon, Feb 07, 2005 at 07:49:04AM +0000, David Laight wrote:
> On Mon, Feb 07, 2005 at 02:42:08PM +1100, matthew green wrote:
> >    
> >    Also I don't believe that the madvise( MAP_SEQUENTIAL) has the desired
> >    effect, and mmaping a large file is probably very bad for the UBC.
> > 
> > 
> > why do you say this?
> 
> What you need to avoid is the UBC discarding all its current pages in order
> to keep all the mapped, and recently faulted in, pages of the file that you
> aren't going to use again in the near future.

um, preventing that behaviour is exactly what MADV_SEQUENTIAL is for.

also, if madvise() is not used, reading a file via mmap() and via read()
currently have exactly the same page replacement behaviour.


I don't understand your other comment either:

> Due to a bug in mmap() the address space isn't counted against ulimit
> until the page is faulted in - so mmapping a large file suceeds, but
> cmp SIGSEGVs when it runs out of address space.

what do you think resource limits have to do with file mappings or page faults?

it sounds more like the mapping included offsets past EOF and the process
tried to access the past-EOF part of the mapping.  SIGSEGV is the correct
response to that.

-Chuck