syscall: add memfd_create() (v3)

v2: Follow the kerndat style that "features" are described
just by global boolean variables.

v3: give NULL as a name to get EFAULT if memfd_create is supported
shmem: rework getting file descriptors for shared memory regions (v2)

/proc/PID/map_files are protected by the global CAP_SYS_ADMIN, so we
need to avoid using them to support user namespaces.

We are going to use memfd_create() to get the first file descriptor and
then all others processes will able to open it via /proc/PID/fd/X.

This patch reworks slave processes to not use map_files.

v2: add more comments
shmem: use memfd_create() to restore shared memory reqions (v2)

/proc/PID/map_files are protected by the global CAP_SYS_ADMIN, so we
need to avoid using them to support user namespaces.

We are going to use memfd_create() to get the first file descriptor and
then all others processes will able to open it via /proc/PID/fd/X.

In this patch memfd_create() is used to get a file descriptor, which is
associated with a shared memory region.

If memfd_create() isn't supported, the old scheme will be used.

v2: don't set a name for memfd. It isn't required.
zdtm/maps01: extend maps01

It's bad idea to have only one target object.
In addition I add a shared region to the second process,
which is not mapped in the first.
travis: add compilation of tests
mount: rework perparation for pivot_root (v2)

We can't bind-mount the required root into itself instead of
resolving a parent mount.

This patch is required to support userns, because if we want to make
pivot_root, the parent mount can't be locked. When we create userns
and mntns, all inherited mounts are marked as locked.

v2: don't change properties of the given root

Cc: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
perf: add ability to trace system calls with perf

First of all perf can trace parasite code. strace can't because ptrace
doesn't allow to attach to one task twice

perf doesn't affect performance so significant as strace and
it allows to trace parasite code. But perf isn't so verbose. For example
it can't show arguments which are tranfered by pointers.

All processes are executed in a new perf_evets cgroup and
"perf record" collects events only for processes from this group.

On dump perf is executed from a network-lock action script, it's a first
point where processes are frozed.
And perf is stopped from post-dump and post-restore, it's the last point
where processes are frozed.

Example of output:
    18.651 ( 0.001 ms): criu/9243 close(fd: 44                                                          ) = 0
    18.655 ( 0.001 ms): criu/9243 gettimeofday(tv: 0x7fff32fdd7f0                                       ) = 0
    18.670 ( 0.013 ms): criu/9243 write(fd: 1023, buf: 0x6b6a00, count: 53                              ) = 53
    18.710 ( 1.078 ms): env00/9226 recvfrom(fd: 3, ubuf: 0x7f963bb95998, size: 12, flags: WAITALL        ) = 12
    18.726 ( 0.014 ms): env00/9226 write(fd: 4, buf: 0x7f963bb95878, count: 26                           ) = 26
    18.761 ( 0.034 ms): env00/9226 mprotect(start: 0x7f963b771000, len: 2093056, prot: READ              ) = 0
zdtm: always show errors

Users don't like errors even if criu returns zero.
So I suggest to start looking at them.
parasite: stop a parasite daemon before dumping threads

The parasite daemon set up SIGCHLD handler, but for dumping threads we
use parasite-trap. While doing this the sigchild handler notices the
CHLD arriving on the thread trap, emits an error

(00.020292) Error (parasite-syscall.c:387): si_code=4 si_pid=3485 si_status=5

but wait() reports -1 (task is not dead, just trapped) and handler just exits.

Let's stop a parasite daemon before dumping threads.
zdtm/static/xids00: print more information about errors
criu: add fault-injection engine

Execute zdtm/live/static/xids00
./xids00 --pidfile=xids00.pid --outfile=xids00.out
Dump 5299
(00.024346) Error (parasite-syscall.c:387): si_code=4 si_pid=5300 si_status=5
(00.031212) Error (parasite-syscall.c:387): si_code=4 si_pid=5301 si_status=5
(00.031227) Error (parasite-syscall.c:398): 5301 was stopped by 5 unexpectedly
pie: Error (pie/parasite.c:429): Trimmed message received (12/0)
Check results 5299
Waiting...
19:27:47.931:  5300: P1 OK
19:27:47.932:  5299: ERR: xids00.c:117: P1 stat 0/0/1/5 (errno = 11 (Resource temporarily unavailable))
19:27:47.932:  5299: FAIL: xids00.c:123: Something failed (errno = 11 (Resource temporarily unavailable))
Test: zdtm/live/static/xids00, Result: FAIL
==================================== ERROR ====================================
Test: zdtm/live/static/xids00, Namespace:
Dump log   : /root/git/criu/test/dump/static/xids00/5299/1/dump.log
--------------------------------- grep Error ---------------------------------
(00.024346) Error (parasite-syscall.c:387): si_code=4 si_pid=5300 si_status=5
(00.031212) Error (parasite-syscall.c:387): si_code=4 si_pid=5301 si_status=5
(00.031227) Error (parasite-syscall.c:398): 5301 was stopped by 5 unexpectedly
pie: Error (pie/parasite.c:429): Trimmed message received (12/0)
pie: Error (pie/parasite.c:429): Trimmed message received (12/0)
------------------------------------- END -------------------------------------
Output file: /root/git/criu/test/zdtm/live/static/xids00.out
------------------------------------------------------------------------------
19:27:47.931:  5300: P1 OK
19:27:47.932:  5299: ERR: xids00.c:117: P1 stat 0/0/1/5 (errno = 11 (Resource temporarily unavailable))
19:27:47.932:  5299: FAIL: xids00.c:123: Something failed (errno = 11 (Resource temporarily unavailable))
------------------------------------- END -------------------------------------
================================= ERROR OVER =================================
zdtm/Makefile: show output for each test

In this case we have another chance to not skip errors.