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

Re: [LTP] mmap001 questions



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.  

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

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

Private version:

$ ./mmap001 -m 100000
mmap001     0  INFO  :  mmap()ing file of 100000 pages or 409600000
bytes
mmap001     1  FAIL  :  mmap() failed: 12: Cannot allocate memory

Shared version:

$ ./mmap001 -m 100000
mmap001     0  INFO  :  mmap()ing file of 100000 pages or 409600000
bytes
mmap001     1  PASS  :  mmap() completed successfully.
mmap001     0  INFO  :  touching mmaped memory
mmap001     2  PASS  :  we're still here, mmaped area must be good
mmap001     3  PASS  :  msync() was successful
mmap001     4  PASS  :  munmap() was successful

--aaron

-- 
Aaron Laffin
Silicon Graphics, Inc. OS Test Development
Email: alaffin@sgi.com Voice: 651-683-5756
USA/MN/EA/F6625/SSBU