[CRIU] [PATCH 04/12] x86: parasite -- Add call_daemon_thread and asm_trap helpers

Cyrill Gorcunov gorcunov at openvz.org
Fri Mar 1 14:04:33 EST 2013


On Fri, Mar 01, 2013 at 10:47:05PM +0400, Pavel Emelyanov wrote:
> > +/*
> > + * Call thread daemon with new stack, the function must
> > + * return the original stack pointer passed in argument
> > + * argument 3
> > + */
> > +#define call_daemon_thread(new_sp, args, s, func)	\
> > +do {							\
> > +	asm volatile ("movq %0, %%rax		\n"	\
> > +		      "movq %1, %%rdi		\n"	\
> > +		      "movq %2, %%rsi		\n"	\
> > +		      "movq %%rsp, %%rdx	\n"	\
> > +		      "movq %%rax, %%rsp	\n"	\
> > +		      "call " #func "		\n"	\
> > +		      "movq %%rax, %%rsp	\n"	\
> > +		      :					\
> > +		      : "g"(new_sp), "g"(args), "g"(s)	\
> > +		      : "rax", "rdi", "rsi", "rdx",	\
> > +		        "rsp", "memory");		\
> > +} while (0)
> 
> O_O What we have in parasite blob does has stack. Why can't we use
> _it_ to run parasite as daemon?

All threads run simultaneously in daemon mode thus every one
needs own stack to work on. Sharing stack from thread leader
simply makes code even more complex.

Letme explain -- we have a thread leader daemon and a set
of regular threads.

Thread leader daemon will use a stack which we statically
allocated for parasite blob, the rest of threads allocate
own stacks.


More information about the CRIU mailing list