Line 1: |
Line 1: |
− | FIXME
| + | == Overview == |
| | | |
− | - write about type of trees
| + | Usually we dump not just a single process but a set of them, where every process may be sharing some resources with other processes. |
− | - use of kcmp syscall
| + | Thus we need somehow to distinguish which resources are shared and which are not. |
− | - internal representation
| |
| | | |
| + | For this sake [http://man7.org/linux/man-pages/man2/kcmp.2.html kcmp] system call has been introduced to Linux kernel. |
| + | It takes two processes and compare a resource asked, returning result similar to well known |
| + | [http://man7.org/linux/man-pages/man3/strcmp.3.html strcmp] call. This allows CRIU to track resources with a sorting algorithm. |
| + | |
| + | === Kcmp-trees === |
| + | |
| + | CRIU gather files, filesystems, vitrual memory descriptors, signal handlers and file descriptors associated with a process |
| + | each into Kcmp-tree. Thus at moment we are carrying five Kcmp-trees. Each declared with <code>DECLARE_KCMP_TREE</code> helper. |
| + | For example |
| + | |
| + | <pre>DECLARE_KCMP_TREE(vm_tree, KCMP_VM);</pre> |
| + | |
| + | Each tree internally represented as [http://en.wikipedia.org/wiki/Red%E2%80%93black_tree red-black] tree. |
| + | |
| + | === Requesting new ID === |
| + | |
| + | When CRIU gathers process resources it check if a resource is already sitting inside of a tree calling |
| + | <code>kid_generate_gen()</code> helper. If a resource is not in a tree - it pushed into a tree |
| + | and a caller obtains new abstract ID which may be used inside CRIU images, otherwise the helper |
| + | returns zero notifying that this kind of resource already known to CRIU and has been handled earlier. |
| + | |
| + | This feature is quite important to eliminate duplication of entries inside CRIU dump images, because |
| + | two processes might share a lot of resources and dumping them multiple times would cause very serious |
| + | performance issue. |
| | | |
| [[Category: Under the hood]] | | [[Category: Under the hood]] |