2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-29 13:28:27 +00:00

57 Commits

Author SHA1 Message Date
Andrey Vagin
b742c125fb mem: fix calculation of a page offset in generate_iovs
The offset should point on a next entry.

Cc: Pavel Tikhomirov <snorcht@gmail.com>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-19 20:09:40 +04:00
Cyrill Gorcunov
bbdc511741 mem: Use pagemap cache
This improve speed if we're dumping a big set of small vmas.

CentOS-6 container
------------------

Without cache

dump: {
	freezing_time: 1705
	frozen_time: 44885
	memdump_time: 9064
	memwrite_time: 15846
	pages_scanned: 246979
	pages_skipped_parent: 0
	pages_written: 2831
	irmap_resolve: 0
}

With cache

dump: {
	freezing_time: 898
	frozen_time: 40859
	memdump_time: 7254
	memwrite_time: 16375
	pages_scanned: 246979
	pages_skipped_parent: 0
	pages_written: 2831
	irmap_resolve: 0
}

1024 VMA, 40K each
------------------
Without cache

dump: {
	freezing_time: 170
	frozen_time: 30372
	memdump_time: 3895
	memwrite_time: 691
	pages_scanned: 13487
	pages_skipped_parent: 0
	pages_written: 61
	irmap_resolve: 0
}

With cache

dump: {
	freezing_time: 231
	frozen_time: 27646
	memdump_time: 768
	memwrite_time: 798
	pages_scanned: 13487
	pages_skipped_parent: 0
	pages_written: 61
	irmap_resolve: 0
}

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-18 12:49:17 +04:00
Andrey Vagin
c6a3b1de27 mem: rename fill_pages into dump_pages
This function splices data from a process to criu,
so dump_pages describes the real meaning.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-14 16:44:58 +04:00
Andrey Vagin
b5dff62e3b mem: use chunk mode for dumping anonymous memory
Before this patch, criu splices all data in pipes and then saves these
data in a image file. Here is a problem, becase creating pipes with big
buffers fails too often, because a kernel tries to allocate a big linear
chunks of memory. Now memory are dumped for a few iterations, where the
size of pipe buffers is restricted.

TODO: need to rework pre-dump, because currently dumping data from
      pipes are postponed. We are going to use sys_process_vm_readv for
      this.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-10 15:06:42 +04:00
Andrey Vagin
4e395c5c8d mem: move code to splice memory into pipes in a separate function
It's preparation to dump memory by chunks.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-10 15:06:40 +04:00
Andrey Vagin
bb98a82098 page-pipe: split dumping memory on chunks (v3)
The problem is that vmsplice() to a big pipe fails very often.

The kernel allocates a linear chunk of memory for pipe buffer
descriptos, but a big allocation in kernel can fail.

So we need to restrict maximal capacity of pipes. But the number of
pipes is restricted too, so we need to split dumping memory on chunks.

In this patch we calculates the pipe size for which vmsplice() will not
fail.

v2: s/batch/chunk and a few other small fixes
v3: Remove callbacks from page_pipes and reuse pipes
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-10 15:06:39 +04:00
Pavel Emelyanov
dc7abdfb92 vma: Don't lookup file_desc for vma twice
We do it first -- on collect, second -- on restore. The
2nd lookup is excessive, we can put fd pointer on vm_area
at lookup and reuse one later.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-07 13:51:29 +04:00
Pavel Emelyanov
490efb4695 files: Properlu count number of users for mmaped/exe-d ghost files
If a file mmaped or pointed by exe link is unlinked, we will
generate a ghost file for it. On restore the ghost file will
be created with the users counter 1 and the very first open
(e.g. for mmap) will unlink the file.

Handle this by bumping up user counter for every mapping
pointing on the file.

This appeared after previous patches that packed the reg-files
image. Before it each vma and exe link created separate entry
in the reg-files image.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-05 16:18:21 +04:00
Pavel Emelyanov
b745ae83b3 vma: Backward compatible VMA restore
If we've found zero VMAs in MmEntry try to look for
VMAs in vma-.img image file.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-04 12:04:33 +04:00
Pavel Emelyanov
54f4f889a5 mm: Move VmaEntries from separate image into Mm one
When writing VMAs we perform too many small writes into vma-.img files.
This can be easily fixed by moving the vma-s into mm-s, all the more
so they cannot be splitted from each other.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-04 11:44:05 +04:00
Pavel Emelyanov
72e462ad67 mm: Read mmentry early
We'll merge mm and vma images, so mm should be read in the
same place where vmas are.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-04 11:44:04 +04:00
Pavel Emelyanov
ed836740ba vma: Don't copy VmaEntry on vma_area
After previous patch is't now possible.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-04 11:44:02 +04:00
Pavel Emelyanov
eb1ae0a025 vma: Turn embeded VmaEntry on vma_area into pointer
On restore we will read all VmaEntries in one big MmEntry object,
so to avoif copying them all into vma_areas, make them be pointable.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-04 11:44:01 +04:00
Pavel Emelyanov
6a5188a2cd vma: Use vma_area_is helper where appropriate (p2)
Lost from c8d5f1a2

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-04 11:43:22 +04:00
Pavel Emelyanov
446fdd7200 rst: Collect VmaEntries only once on restore
Right now we do it two times -- on shmem prepare and
on the restore itself. Make collection only once as
we do for fdinfo-s -- root task reads all stuff in and
populates tasks' rst_info with it.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-03 23:35:03 +04:00
Pavel Emelyanov
0786f831d7 mem: Move shmem preparation routine and rename
We'll collect VmaEntries early before fork.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-03 23:34:12 +04:00
Pavel Emelyanov
593cb59a63 pagemap: Use pread to read pagemap entries
When reading pagemaps, we read it from specific position. To
do it, we called lseek, then read. Fortunetely, there's a
syscall that does both things in one call -- pread. Since
we don't need to keep pagemap's position for further reads,
it perfectly suits our needs.

This removes 75% of lseek calls when dumping basic container.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-03 00:30:02 +04:00
Andrey Vagin
af510ae01a mm: don't dump the zero page
If someone reads untouched page, the kernel maps the zero page
to this address. This page will not have the SOFT_DIRTY bit and it must
not be dumped.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-30 14:31:39 +04:00
Pavel Emelyanov
bfc2895f2a dump: Move pagemap parent checks from mem-dump to page-xfer
When writing pagemaps to page-server we want both page-*.img and pagemap-*.img
to be on remote host. But the subsequent pre-dump/dump with parent images will
try to access pagemap-*img-s to check for hole dumped being present in it.

To handle this, move checks for hole being backed by something in parent into
page-local-xfer. In case of page-server dump it will be page-server who will
check the holes when writing them.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-24 16:02:57 +04:00
Andrey Vagin
e36250ef7e mem: handle errors of page_xfer_dump_pages()
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-23 13:27:14 +04:00
Pavel Emelyanov
04fde2e178 mem: Don't track memory changes if --track-mem is not specified
We have a big mistake in how we track for ptes to be SOFT_DIRTY -- no
need in these checks if the --track-mem is not given.

While fixing this, remember proper checks for the kernel memory tracker.

Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Reported-by: Tim Schürmann <info@tim-schuermann.de>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-16 22:07:44 +04:00
Kir Kolyshkin
d64d68d66c whitespace-at-eol cleanup
Remove whitespace at EOL (found by git grep ' $')

To people using vim, I'd suggest adding the following code to ~/.vimrc:

let c_space_errors = 1
highlight FormatError ctermbg=darkred guibg=darkred
match FormatError /\s\+$\|\ \+\t\|\%80v.\|\ \{8\}/

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-12 10:00:45 +04:00
Cyrill Gorcunov
8f64a14a03 headers: Move fcntl related data to include/fcntl.h
fcntl data is arch independent, so move it out of include/asm/type.h

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-14 22:13:10 +04:00
Andrey Vagin
4850fd94a8 crtools: move cr_options in a separate header
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-06 18:17:52 +04:00
Andrey Vagin
0d1dfc2e08 crtools: move all stuff about vma together
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-06 12:43:49 +04:00
Andrey Vagin
824403a009 crtools: create new header for servicefd stuff (v2)
v2: generate patch relative to the official git.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-06 12:43:02 +04:00
Pavel Emelyanov
987de2de05 parasite: Rename ack-waiting function to look better
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-17 08:56:17 +04:00
Pavel Emelyanov
f2978d2ac7 parasite: Reshuffle sync and async daemon-node executing routines
The version, that might not wait for ack is always called with
"async" flag set. Cleanup things according to this.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-17 08:54:24 +04:00
Cyrill Gorcunov
93e60c76ee mem: Add missing EOL into pr_warn
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-15 18:48:57 +04:00
Pavel Emelyanov
0b5170c0fc mem: Remove pagemap2 mentions
This file was created for backward compatibility with
not-yet-patched kernel. Now we can remove it.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-02 09:51:33 +04:00
Pavel Emelyanov
0f96026192 mem: Lower messages severity for inability to reset dirty tracker
The _actual_ need for this is checked in other place.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-02 09:15:50 +04:00
Pavel Emelyanov
1edb5b01f3 mem: Don't ignore memory tracking reset errors
Otherwise on non-soft-dirty kernel dump passes, but
produces broken image.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-01 21:26:35 +04:00
Andrey Vagin
dd38ae16d1 mm: handle new processes which created between snapshots (v2)
These processes don't have image files in a parent snapshot and crtools
should not fail in this case.

https://bugzilla.openvz.org/show_bug.cgi?id=2636

v2: return NULL from mem_snap_init, if a parent image is absent.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-06-27 23:47:15 +04:00
Alexander Kartashov
5bf83eaf69 mem: don't screen page dump failure
This patch prevents page dump failure screening
by the PARASITE_CMD_MPROTECT_VMAS command success.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-06-22 13:17:28 +04:00
Andrey Vagin
11d3adbf56 parasite: remove code which used for daemonized threads
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-27 16:45:24 +04:00
Andrey Vagin
595b772ad2 parasite: Switch parasite to daemon mode (v2)
Parasite daemon mode it quite tricky. One may consider
it as consisting of two parts

 - daemon mode for thread leader
 - daemon mode for regular threads

Thread leader daemon
--------------------

Once thread leader parasite code switched initialized,
it starts spinning on socket listening for commands
to handle.

If the command destination is the thread leader itself it
handles it and replies back the ack to the caller (iow
the main crtools code).

If the recepient is not thread leader but one of threads,
then thread leader wakes up the thread by futex and makes
it to handle the command waiting on futex for result. Once
result obtained, the ack is being sending back to caller.

Thread daemon
-------------

On initialization thread daemon starts waiting a command on futex.
The futex is triggered by thread leader daemon when command received.
Once command is received and handled, the result is reported back to
the thread leader daemon, which in turn send ack message.

Both thread-leader and regular threads require own stack to operate
on since they all are present in memory simultaneously. Thus we use
call_daemon_thread() helper which takes care of providing stack
to the callee.

TODO:

 - ARM requires own wrappers on damonize/trap low-level code,
   at moment x86-64 is only covered

v2: remove PARASITE_CMD_DAEMONIZED and s->ack
    parasite: use a propper command for getting ack

Fixed-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 20:22:23 +04:00
Cyrill Gorcunov
fe13977b1e parasite-syscall: Add "trap" postfix to parasite execute functions
They are relying on trap being issued at the end of execution
so to distinguish it with future daemon mode add "trap" postfix
to them.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 19:57:55 +04:00
Cyrill Gorcunov
58cb8b2769 pagemap: Move PME_ constants to the header
This constants are system wide, so move them to mem.h
header for reuse sake.

[ xemul: It was kerndat.h in the patch ]

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-23 12:50:43 +04:00
Pavel Emelyanov
61c6360c1d mem: Update soft-dirty detection to work on -mm tree
The soft-dirty API has changed slightly -- now the bit in
question _is_ in pagemap file (not pagemap2) but to see it
we have to reset soft-dirty for anyone first.

Teach the kerndat soft-dirty checker this fact. The actual
pagemap reading code already knows select pagemap/pagemap2
file itself.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-17 16:13:49 +04:00
Pavel Emelyanov
bfe77ea725 mem: Add comments
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-16 00:38:26 +04:00
Pavel Emelyanov
12820d9bf6 stats: Don't account mem-write time into mem-dump time for regular dump
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-15 15:57:40 +04:00
Pavel Emelyanov
37c137092b mem/stats: Add stats about memory dumping
pages_scanned -- the amount of pages criu looked at for decision
pages_skipped_parent -- the amount of pages that were skipped, due to
                        they are present in parent image
pages_writted -- the amount of pages criu transfered into image

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-15 15:46:07 +04:00
Pavel Emelyanov
a533820b7e dump: Introduce the pre-dump action
With this action criu will seize tasks, grab all its memory into
page-pipes, rest dirty tracker and will then release them. Writing
the memory from page-pipes would occur after tasks are unfreezed
and thus the frozen time should become reasonably small.

When pre-dump is in action, the dirty tracking is forcedly turned
off as well as tasks are resumed afterwards, not killed, by default.

This is a prerequisite for iterative migration.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-14 12:00:40 +04:00
Pavel Emelyanov
094330c33b stats: Add writing-memory-image timing
Dumping memory is draining it from parasite, for pre-dump
this time would be reasonably small. _Writing_ the memory
would occur _after_ tasks unseize and resume.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-14 11:52:45 +04:00
Pavel Emelyanov
d416e6a135 mem-snap: Redefine CLI options for mem snapshot
They are not documented, thus OK for now. Two options --
* one to specify where the parent images are
* one to reset dirty memory tracking

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-14 11:04:57 +04:00
Pavel Emelyanov
d9c3b91cf1 mem: Place mprotect and dump_pages args in one parasite args area
This is required for (soon to be) pre-dump command -- this command
will have to keep parasite args with pagemap (iovecs) some time after
parasite is executed. Since we call mprotect cmd _after_ pages dump
we can thus spoil these iovecs. To address this vmas to mprotect and
iovecs to dump are located in one parasite args area one after another
without intersections.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-14 11:02:18 +04:00
Pavel Emelyanov
eb41d26d4a pages: Rename parasite args->nr to args->nr_segs
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-13 23:05:37 +04:00
Pavel Emelyanov
c15d4ee66a dump: Cleanup dump_pages_seized arguments and declaration
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-13 14:09:19 +04:00
Pavel Emelyanov
1e18128423 stats: Dump-time statistics
Basic timings for dump (freeze, frozen, mem dump).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-13 13:53:31 +04:00
Pavel Emelyanov
a3872dbead mem: Treat /proc/pid/pagemap2 file as optional
It will appear not earlier than in 3.10.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-23 23:22:25 +04:00