page-pipe: move tunable constants into config.h

PIPE_MAX_SIZE is calculated according with the kernel code.
PPB_IOV_BATCH has been taken from my mind.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
shmem: use chunk mode for dumping shared 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.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
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>
proc_parse: Set bigger buffer for smaps FILE

We spend a lot of time reading the /proc/$pid/smaps file. The time
is spent in two places:

1 kernel puts too many info into it
2 fgets pulls info in 1024-bytes chunks, info about one vma is
  typically bigger (up to 3k bytes) thus we call read() ~3 times
  per one vma, which increases the amount of time spent in kernel
  to re-fill this info

Setting the internal buffer to PAGE_SIZE size reduces the amount of
read()-s on ~60% during basic container dump. Setting bigger buffer
doesn't work, as kernel's seq file engine feeds at most one page of
data per read syscall regardless of the buffer size.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
vdso: Get pagemap entries with pread call

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by:Andrew Vagin <avagin@parallels.com>
image: Don't unlink image we're dumping into

We want to write into empty image files, so we
unlink them before dumping into. Let's O_TRUNC
it instead.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
systemd: start criu-service with log at /var/log

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Acked-by: Vladimir Davydov <vdavydov@parallels.com>
Acked-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
install: install criu-service logrotate config

Thank Vladimir Davydov <vdavidov@parallels.com> for help and config.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Acked-by: Vladimir Davydov <vdavydov@parallels.com>
Acked-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Complete the conversion to SRCARCH

Signed-off-by: Christopher Covington <cov@codeaurora.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Force symlink creation

Otherwise the build can fail with the following message.

ln: .../libcriu.so.1: File exists
make: *** [install] Error 1

Signed-off-by: Christopher Covington <cov@codeaurora.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
pagemap-cache: Introduce engine

Pavel reported that in case if there a big number
of small vmas present in the dumpee we're reading
/proc/pid/pagemap too frequently.

To speedup this procedue we inroduce pagemap cache.

The interface is:
 - pmc_init/pmc_fini for cache initialization and freeing
 - pmc_get_map to retrieve specific PMEs array for VMA area

v2:
 - Move internal constants to pagemap-cache.c
 - Make PAGEMAP_LEN to accept virtual address/size
 - Don't adjust low bound in caching mode to save a couple of code bytes

Reported-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
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>
config-base: Beautify header

 - drop empty line
 - end ending endif comment

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
config-base: Add F_SETPIPE_SZ/F_GETPIPE_SZ

These are needed to compile project on CentOS 6.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>