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>