criu/include
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
..
asm-generic asm: Add builtin_memcpy, builtin_memcmp generic helpers 2013-05-23 16:51:14 +04:00
bug.h clang: add an exception for BUG_ON_HANDLER 2013-04-04 14:00:21 +04:00
compiler.h include/compiler.h: Cleanup 2013-02-15 17:34:38 +04:00
cpu.h cpu: Make cpu routines being per-acrh 2013-02-18 18:42:08 +04:00
crtools.h protobuf: Prepare scaffolds for procfs NS entries 2013-05-18 03:37:00 +04:00
err.h headers: Add err.h header 2013-04-02 20:27:51 +04:00
eventfd.h show: Remove options args from ->show callback 2013-05-08 00:23:42 +04:00
eventpoll.h show: Remove options args from ->show callback 2013-05-08 00:23:42 +04:00
fifo.h files: pass a file descriptor on an fdinfo image instead of cr_fdset 2013-01-11 14:47:09 +04:00
file-ids.h headers: Change "../protobuf/" to "protobuf/" 2013-02-15 17:33:06 +04:00
file-lock.h lock: Show long option in log message about using one 2013-03-27 20:17:59 +04:00
files-reg.h headers: Change "../protobuf/" to "protobuf/" 2013-02-15 17:33:06 +04:00
files.h ns: Add c/r for /proc/$pid/ns/$ids references 2013-05-18 04:00:05 +04:00
fsnotify.h show: Remove options args from ->show callback 2013-05-08 00:23:42 +04:00
image.h headers: image.h -- Drop asm/types.h inclusion 2013-04-02 20:29:15 +04:00
inet_diag.h headers: Unify include guards (in comments) and a few fixes 2012-12-25 22:40:24 +04:00
ipc_ns.h show: Remove options args from ->show callback 2013-05-08 00:23:42 +04:00
kcmp-ids.h headers: Unify include guards (in comments) and a few fixes 2012-12-25 22:40:24 +04:00
kerndat.h soft-dirty: Check that kernel reports soft-dirty bits 2013-04-15 13:24:32 +04:00
libnetlink.h headers: Unify include guards (in comments) and a few fixes 2012-12-25 22:40:24 +04:00
list.h headers: list.h -- Add hlist helpers 2013-04-02 20:29:25 +04:00
lock.h locks: add futex_wait_while_eq 2013-05-24 16:43:26 +04:00
log-levels.h headers: Unify include guards (in comments) and a few fixes 2012-12-25 22:40:24 +04:00
log.h log: Make pr_err_once to use pr_err 2013-01-14 14:26:07 +04:00
magic.h protobuf: Prepare scaffolds for procfs NS entries 2013-05-18 03:37:00 +04:00
mem.h mem: Add PME_ bits for page frame retrieval 2013-05-23 12:51:27 +04:00
mount.h show: Remove options args from ->show callback 2013-05-08 00:23:42 +04:00
namespaces.h ns: Add c/r for /proc/$pid/ns/$ids references 2013-05-18 04:00:05 +04:00
net.h show: Remove options args from ->show callback 2013-05-08 00:23:42 +04:00
netfilter.h headers: Unify include guards (in comments) and a few fixes 2012-12-25 22:40:24 +04:00
netlink_diag.h crtools: add netlink_diag.h 2013-03-26 00:23:13 +04:00
packet_diag.h headers: Unify include guards (in comments) and a few fixes 2012-12-25 22:40:24 +04:00
page-pipe.h mem: Comment page-read, page-xfer and page-pipe 2013-04-16 11:34:53 +04:00
page-read.h mem: Comment page-read, page-xfer and page-pipe 2013-04-16 11:34:53 +04:00
page-xfer.h page-server: allow to execute page-server in the background (v2) 2013-05-20 15:00:40 +04:00
parasite-syscall.h parasite: Switch parasite to daemon mode (v2) 2013-05-24 20:22:23 +04:00
parasite.h parasite: Prepare structures for daemon mode 2013-05-24 20:09:39 +04:00
pipes.h headers: Change "../protobuf/" to "protobuf/" 2013-02-15 17:33:06 +04:00
proc_parse.h mount: free all parts of mnt entries 2013-04-10 01:26:59 +04:00
protobuf.h protobuf: Prepare scaffolds for procfs NS entries 2013-05-18 03:37:00 +04:00
pstree.h parasite: use transparent thread indexes 2013-05-24 18:47:11 +04:00
ptrace.h crtools: dump pending signals (v4) 2013-03-25 23:43:37 +04:00
rbtree.h x86: moved x86-specific files into the directory arch/x86. 2013-01-09 17:02:47 +04:00
restorer.h restore: construct sigframe in crtools 2013-05-24 17:39:52 +04:00
shmem.h headers: Change "../protobuf/" to "protobuf/" 2013-02-15 17:33:06 +04:00
sigframe.h restore: construct sigframe in crtools 2013-05-24 17:39:52 +04:00
signalfd.h show: Remove options args from ->show callback 2013-05-08 00:23:42 +04:00
sk-inet.h show: Remove options args from ->show callback 2013-05-08 00:23:42 +04:00
sk-packet.h show: Remove options args from ->show callback 2013-05-08 00:23:42 +04:00
sk-queue.h show: Remove options args from ->show callback 2013-05-08 00:23:42 +04:00
sockets.h show: Remove options args from ->show callback 2013-05-08 00:23:42 +04:00
stats.h mem/stats: Add stats about memory dumping 2013-05-15 15:46:07 +04:00
syscall-types.h x86: syscall -- Add sys_prlimit64 call 2013-05-23 15:12:57 +04:00
sysctl.h headers: Unify include guards (in comments) and a few fixes 2012-12-25 22:40:24 +04:00
tty.h tty: More descriptive log message about --shell-job requirement 2013-03-27 20:11:00 +04:00
unix_diag.h x86: moved x86-specific files into the directory arch/x86. 2013-01-09 17:02:47 +04:00
util-net.h headers: Unify include guards (in comments) and a few fixes 2012-12-25 22:40:24 +04:00
util.h proc: use vma flags for determing vmas with MAP_GROWSDOWN 2013-05-21 19:03:57 +04:00
uts_ns.h show: Remove options args from ->show callback 2013-05-08 00:23:42 +04:00
vdso.h vdso: Add vdso_put_mark helper 2013-05-24 16:39:41 +04:00
xmalloc.h headers: util.h -- Move memory helpers to xmalloc.h 2013-04-02 21:15:27 +04:00