Does Linux treat pages in read-only mmap files differently than "regular" pages in the page cache?

134 views Asked by At

Let say I have a file that's exactly 4096 bytes long.

(a) I open the file using open(2) and read its entire content. Close the file.

vs

(b) I open the file, mmap its fd with PROT_READ, read the entire content of the buffer, close the fd but do NOT release the buffer using munmap.

I assume in both cases, the file's single page will be put in the page cache (so a future attempt to read this file requires no disk IO)

My question is -- when the system runs out of physical memory, and needs to drop some pages from the page cache, will it prefer to drop the "regular pages" (a) over the "mmaped pages" (b)?

0

There are 0 answers