When doing live migration, a lot of time is used by the procedure of copying tasks' memory to the destination host. Note that the processes are frozen during that time. Acting like in the previous example also reduces the freeze time, i.e. the live migration becomes more live.

In order to find out which memory pages have changed, we patched the kernel. Tracking the memory changes consists of two steps:

ask the kernel to keep track of memory changes (by writing 4 into /proc/$pid/clear_refs file for each $pid we are interested in).

and, after a while,

get the list of modified pages of a process by reading its /proc/$pid/pagemap file and looking at so called soft-dirty bit in the pagemap entries.

During the first step, kernel will re-map all the tasks' mapping in read-only manner. If a task then tries to write into any of its pages, a page fault will occur, and the kernel will note which page is being written to. Reading the pagemap file reveals this information.

command should say the feature is supported. The memory changes tracking was initially merged into Linux kernel v3.11, and was further polished until v3.18 (see Upstream kernel commits for details).

There are several command line options to use the functionality:

--prev-images-dir option

This option is used to provide the path where images from a previous dump or pre-dump (see below) action reside. If possible, CRIU will dump only the memory pages that have been modified since that time.

--track-mem option

This option makes CRIU to reset memory changes tracker. If done, the next dump --prev-images-dir will have chances to successfully find not changed pages.

pre-dump action

This action dumps only part of the information about processes and does that by keeping tasks frozen for the shortest possible time. The images generated by pre-dump cannot and should not be used for restore. After this action the proper dump should be performed with properly configured --prev-images-dir path.