Find which pages are no longer used when copying to write

Let's say I have a process in Linux from which I am fork()another identical process. After forking, when the source process starts writing to memory, the Linux write-write mechanism will provide the process with unique pages of physical memory that are different from those used by the forked process.

How can I at some point in the execution find out which pages of the original process were copied to the record?

I do not want to use the SIGSEGV signal handler and provide read-only access to all pages at the beginning, as this causes overhead that I do not want.

+3
source share
2 answers

syscall - fork(), clone():

copy_process() → copy_mm() → dup_mm() → dup_mmap() → , VMA VMA, "copy-on-write":

http://www.cs.columbia.edu/~krj/os/lectures/L17-LinuxPaging.pdf

http://www.cs.columbia.edu/~junfeng/13fa-w4118/lectures/l20-adv-mm.pdf

(. ), PTE ( ), VMA ( ) - , .

.

+1

, .

, pread/proc/self/pagemap (64 , 8 * (addr/PAGE_SIZE)), PFN ( 54 ). PFN /proc/kpagecount, , .

, PFN pagemap .

, - , Pss ( ) /proc/smaps.

0

All Articles