Changes

873 bytes added ,  19:40, 11 December 2012
Added introduction to the problem
Line 1: Line 1: −
== How it works now ==
+
== Problem ==
=== Restoring ===
+
Private anonymous mappings are tricky. They are declared to belong to a single process only and contain ''its'' data, but the Linux kernel optimizes the case when task calls fork() and creates a copy of himself. In this case all private anonymous mappings are "shared" between the parent and the child, but when either of them tries to modify the memory, the respective page is duplicated and the changes occur in the modifier's copy only.
 +
 
 +
When taking a dump of a process tree, it's totally correct to copy contents of all the anonymous private mappings independently and restore them in the same way -- just mmap and put the memory in there. But with this approach we effectively do the described memory duplication and thus increase memory usage by checkpointed and restore application.
 +
 
 +
To fix this, crtools in version 0.3 and above do special tricks.
 +
 
 +
== How restore works to keep COW intact ==
 
We have different ideas how to restore {{Abbr|COW|Copy-on-write}}<ref>[[wikipedia:Copy-on-write]]</ref> memory. In a moment we even thought to use {{Abbr|KSM|Kernel Shared Memory}}<ref>[[wikipedia:Kernel SamePage Merging (KSM)]]</ref> for that. As result we found a good way for restoring COW memory (I guess). All {{Abbr|VMA|Virtual Memory Area}}s are restored in the same way as they were created. Here are two questions:
 
We have different ideas how to restore {{Abbr|COW|Copy-on-write}}<ref>[[wikipedia:Copy-on-write]]</ref> memory. In a moment we even thought to use {{Abbr|KSM|Kernel Shared Memory}}<ref>[[wikipedia:Kernel SamePage Merging (KSM)]]</ref> for that. As result we found a good way for restoring COW memory (I guess). All {{Abbr|VMA|Virtual Memory Area}}s are restored in the same way as they were created. Here are two questions: