<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://criu.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Paschalis+Mpeis</id>
	<title>CRIU - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://criu.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Paschalis+Mpeis"/>
	<link rel="alternate" type="text/html" href="https://criu.org/Special:Contributions/Paschalis_Mpeis"/>
	<updated>2026-05-13T11:22:24Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.6</generator>
	<entry>
		<id>https://criu.org/index.php?title=Memory_changes_tracking&amp;diff=1868</id>
		<title>Memory changes tracking</title>
		<link rel="alternate" type="text/html" href="https://criu.org/index.php?title=Memory_changes_tracking&amp;diff=1868"/>
		<updated>2014-12-10T23:29:57Z</updated>

		<summary type="html">&lt;p&gt;Paschalis Mpeis: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CRIU can detect what memory pages a task (or tasks) has changed since some moment of time. This page describes why this thing is required, how it works and how to use it.&lt;br /&gt;
&lt;br /&gt;
== Why do we need to track memory changed ==&lt;br /&gt;
&lt;br /&gt;
There are several scenarios when detecting what parts of memory has changed is required:&lt;br /&gt;
&lt;br /&gt;
; [[Incremental dumps]]&lt;br /&gt;
: When you take a series of dumps from a process tree, it is a very good optimization not to dump ''all'' the memory every time, but get only those memory pages that has changed since previous dump&lt;br /&gt;
&lt;br /&gt;
; Smaller freeze time for big Applications&lt;br /&gt;
: When a task uses a LOT of memory, dumping it may take time and during all this time this task should be frozen. To reduce the freeze time we can&lt;br /&gt;
* get memory from task and start writing it in images&lt;br /&gt;
* freeze task and get only changed memory from it&lt;br /&gt;
&lt;br /&gt;
; [[Live migration]]&lt;br /&gt;
: When doing live migration a lot of time takes the procedure of copying tasks' memory on remote host. And yet again, during this time process is frozen. Acting like in the previous example also reduces the freeze time, i.e. -- the live migration becomes really Live.&lt;br /&gt;
&lt;br /&gt;
== How we track memory changes ==&lt;br /&gt;
&lt;br /&gt;
In order to find out what pages in memory has changed, we [http://lwn.net/Articles/546966/ patched] the kernel. Tracking the memory changes consists of two steps:&lt;br /&gt;
&lt;br /&gt;
* Tell the kernel that we want it to keep track of memory changes by particular task by writing 4 into &amp;lt;core&amp;gt;/proc/$pid/clear_refs&amp;lt;/code&amp;gt; file.&lt;br /&gt;
&lt;br /&gt;
and after a while&lt;br /&gt;
&lt;br /&gt;
* Get what pages were modified by task by reading its &amp;lt;code&amp;gt;/proc/$pid/pagemap&amp;lt;/code&amp;gt; file and looking at so called ''soft-dirty'' bit in the pagemap entries.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On the first step kernel will re-map all the tasks' mapping in read-only manner. If a task will try to write into one of its pages later, a page fault would occur and the kernel would note which page was written to. Reading the &amp;lt;code&amp;gt;pagemap&amp;lt;/code&amp;gt; file reveals this information.&lt;br /&gt;
&lt;br /&gt;
== How to use this with CRIU ==&lt;br /&gt;
&lt;br /&gt;
First of all, the&lt;br /&gt;
&lt;br /&gt;
 #criu check&lt;br /&gt;
&lt;br /&gt;
command (without the &amp;lt;code&amp;gt;--ms&amp;lt;/code&amp;gt; option) should sat, that everything is OK. The thing is that the soft-dirty tracker is not yet merged upstream, thus you should make sure, that you're using the properly patched kernel.&lt;br /&gt;
&lt;br /&gt;
There are several options how this functionality can be used.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;--prev-images-dir&amp;lt;/code&amp;gt; option&lt;br /&gt;
:This option says where the images from previous &amp;lt;code&amp;gt;dump&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;pre-dump&amp;lt;/code&amp;gt; (see below) action reside. If possible, CRIU will not dump memory pages that hasn't changed since that time.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;--track-mem&amp;lt;/code&amp;gt; option&lt;br /&gt;
:This option makes CRIU to reset memory changes tracker. If done, the next dump &amp;lt;code&amp;gt;--prev-images-dir&amp;lt;/code&amp;gt; will have chances to successfully find not changed pages.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;pre-dump&amp;lt;/code&amp;gt; action&lt;br /&gt;
:This action dumps only part of information about processes and does this keeping tasks frozen for minimally possible time. The images generated by pre-dump cannot and should not be used for restore. After this action the proper &amp;lt;code&amp;gt;dump&amp;lt;/code&amp;gt; should be performed with properly configured &amp;lt;code&amp;gt;--prev-images-dir&amp;lt;/code&amp;gt; path.&lt;br /&gt;
&lt;br /&gt;
[[Category:Under the hood]]&lt;/div&gt;</summary>
		<author><name>Paschalis Mpeis</name></author>
	</entry>
	<entry>
		<id>https://criu.org/index.php?title=Remote_syscall_execution&amp;diff=1867</id>
		<title>Remote syscall execution</title>
		<link rel="alternate" type="text/html" href="https://criu.org/index.php?title=Remote_syscall_execution&amp;diff=1867"/>
		<updated>2014-12-10T15:32:33Z</updated>

		<summary type="html">&lt;p&gt;Paschalis Mpeis: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes how the &amp;lt;code&amp;gt;exec&amp;lt;/code&amp;gt; command in criu works.&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;exec&amp;lt;/code&amp;gt; command executes arbitrary system call from another task's context. It does so by exploiting the parasite code execution feature, which is also used to dump various process' information.&lt;br /&gt;
&lt;br /&gt;
== Syntax ==&lt;br /&gt;
&lt;br /&gt;
The command syntax is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
criu exec -t &amp;lt;pid&amp;gt; &amp;lt;syscall-name&amp;gt; &amp;lt;syscall-arguments&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;syscall-name&amp;lt;/code&amp;gt; is just a name of a system call. Since typically each syscall is wrapped with the respective glibc function, you can find out information about the interesting system call in the respective man page.&lt;br /&gt;
&lt;br /&gt;
The rest of the command line is treated as &amp;lt;code&amp;gt;syscall-arguments&amp;lt;/code&amp;gt;. Each command line argument in this list is converted into the system call argument by the following rules:&lt;br /&gt;
&lt;br /&gt;
* If an argument starts with '&amp;amp;', the rest of it is copied to the target task's address space (it's allocated by remotely calling the &amp;lt;code&amp;gt;mmap&amp;lt;/code&amp;gt; syscall) and the pointer to this area is passed as the system call argument&lt;br /&gt;
&lt;br /&gt;
* If an argument starts with '@', the rest of it is considered to be a size of a memory buffer, pointer to which is passed into a syscall and which contents is printed on the screen after the syscall returns. Note, that before pushing the argument into the syscall, the memory is ''not'' initialized.&lt;br /&gt;
&lt;br /&gt;
* Otherwise, the argument is converted into an &amp;lt;code&amp;gt;unsigned long&amp;lt;/code&amp;gt; number with &amp;lt;code&amp;gt;strtol&amp;lt;/code&amp;gt; and passed to system call directly&lt;br /&gt;
&lt;br /&gt;
* Not specified arguments (if required by system call) are set to 0&lt;br /&gt;
&lt;br /&gt;
In order to execute a system call for remote task, you don't have to be root -- you should only have rights to do debugging (strace) on it.&lt;br /&gt;
If you want to make task perform some action, that consists of several syscalls, you should first stop it with &amp;lt;code&amp;gt;SIG_STOP&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Re-opening stdout ===&lt;br /&gt;
&lt;br /&gt;
You can close the 1st fd from a task and re-open it into some other file like this&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# criu exec -t &amp;lt;pid&amp;gt; close 1&lt;br /&gt;
# criu exec -t &amp;lt;pid&amp;gt; open '&amp;amp;&amp;lt;path-to-file&amp;gt;' 2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the 2nd string 2 means the &amp;lt;code&amp;gt;O_RDWR&amp;lt;/code&amp;gt; opening mode.&lt;br /&gt;
&lt;br /&gt;
=== Adding madvise-s to a mapping ===&lt;br /&gt;
&lt;br /&gt;
You can tune the task's address space with &amp;lt;code&amp;gt;madvise&amp;lt;/code&amp;gt; bits like this&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# criu exec -t &amp;lt;pid&amp;gt; madvise &amp;lt;start&amp;gt; &amp;lt;lenght&amp;gt; &amp;lt;madvise-bits-value&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Paschalis Mpeis</name></author>
	</entry>
</feed>