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>
Showing
Please
register
or
sign in
to comment