[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [LTP] mmap001 questions



>>>>> "aaron" == Aaron Laffin <alaffin@sgi.com> writes:

aaron> Robert Williamson wrote:
>> Using this
>> test I'm able to push the memory to the limit of crashing the box, but if I
>> specify more memory than I actually have the appropriate "Cannot allocate
>> memory" message occurs and the test is aborted.  

aaron> What syscall does this error message come from?  Is it ENOMEM?  Then,
aaron> what type of mapping are you using?  mmap001 uses a shared mapping,
aaron> meaning changes to the pages are flushed to the file itself.  A private
aaron> mapping is very different in that changes are copy on write and those
aaron> changes are supported by normal paging mechanisms.  So, a private
aaron> mapping is at the mercy of the ram size and swap size.

aaron> To test this theory, I changed mmap001, replaceing MAP_SHARED with
aaron> MAP_PRIVATE.  Then I ran it on the same system in both modes.

A private mmap can only be as big as memory + swap (and normally it
fails indded for sizes smaller than that).  For MAP_SHARED maps, you
always can put things in the file that you are mapping from.  in the
MAP_PRIVATE case, you can't.  You only have the memory + swap
available at that moment.

Later, Juan "who also thinks that the MAP_{SHARED,PRIVATE} semantic
are not the cleaner/expected ones in the Unix API".

-- 
In theory, practice and theory are the same, but in practice they 
are different -- Larry McVoy