Is the executable code uniquely stored in tmpfs, copied to a different part of RAM on startup?

An executable on disk must first load code and data statements into it before it can be run. When the executable is stored in tmpfs, is it already in RAM, just like the kernel bypasses the step of loading the executable into RAM by simply mapping the tmpfs pages into the process address space? Does the answer answer for both executables and loaded libraries?

+3


source to share


1 answer


Your question was answered on a post on the Linux kernel mailing list in 2007

(Since tmps is a storage scheme in filesystem caching code, no backing store, said buffer cache should be considered "original")

Philip Susi asked:

The question is, when you execute a binary on tmpfs, does its code segment get displayed directly where it is in the buffer cache, or is it copied to another page for the execution process? At least assuming it's possible due to the offset of the vma and the file of the segment being aligned.



And Hugh Dickens answered

Its pages are displayed directly during execution without copying.

You might want to read the full stream - a note is made that this depends on the existence of a system with an MMU, and then the discussion moves to tmpfs non-persistence.

Attempting to copy-to-write Linux would mean that any page of data you write to will get a unique copy created for your process during the first write.

+2


source







All Articles