Find the answer to your Linux question:
Results 1 to 2 of 2
A while back, an mmap() read-only for a file would allocate swap space for that memory area in case there was a need to swap out that data in the ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2008
    Location
    North East U.S.
    Posts
    30

    Does a read-only mmap of a file consume swap space?


    A while back, an mmap() read-only for a file would allocate swap space for that memory area in case there was a need to swap out that data in the future. Does this still happen? AIX always just dropped the pages and a page-fault would go back to the file to get them if needed, so there is really no need for swap space to cover the pages mapped read-only for a file. I am just wondering if Linux ever changed to not require swap space to back up such mmap() requests. Thanks!

  2. #2
    Just Joined!
    Join Date
    Jun 2008
    Location
    North East U.S.
    Posts
    30
    Since a read-only mmap of a file cannot be modified, the pages should never end up "dirty". The question then is simply whether such pages would be discarded and read back in from the file or written to swap space the first time and then read back from there. Does it make any different if it is MAP_SHARED vs MAP_PRIVATE?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •