[CRIU] [PATCH] seize: Take --timeout option into account when freezing processes

Cyrill Gorcunov gorcunov at virtuozzo.com
Fri May 27 12:37:22 PDT 2016


On Fri, May 27, 2016 at 10:18:17PM +0300, Pavel Emelyanov wrote:
> On 05/26/2016 04:46 PM, Cyrill Gorcunov wrote:
> > When we're freezing processes we don't count on anything but
> > rather do 5 attempts with constantly increasing delay.
> > 
> > Lets rather do the following:
> > 
> >  - take --timeout option into account (which is 5 seconds
> >    by default) and split it into 100 ms steps;
> 
> Increasing delays make sense I would say. Would you keep them?

Not right now. Constant step makes computations easier here.
Note that we're taking into account the argument right now
and can calcs step in one pass instead of adding some
exponential aproximation (we could of course but I think
as a first step bette to keep it simplier).

> >  
> >  static int freeze_processes(void)
> >  {
> > -	int i, fd, exit_code = -1;
> > +	int fd, exit_code = -1;
> >  	char path[PATH_MAX];
> >  	const char *state = thawed;
> >  
> > +	static const unsigned long step_ms = 100;
> > +	unsigned long nr_attempts = (opts.timeout * 1000000) / step_ms;
> > +	unsigned long i;
> > +
> > +	const struct timespec req = {
> > +		.tv_nsec	= step_ms * 1000000,
> > +		.tv_sec		= 0,
> > +	};
> > +
> > +	if (unlikely(!nr_attempts)) {
> 
> "If timeout if off" means if (!opts.timeout) ;)

One can increase @step_ms one day and integer arithmetics
end up with nr_attempts = 0 but opts.timeout != 0, so
@nr_attempts should be used here. But true, comment is
misleading a bit ;)

> > +		/*
> > +		 * If timeout is turned off, lets
> > +		 * wait for at least 10 seconds.
> > +		 */
> > +		nr_attempts = (10 * 1000000) / step_ms;
> 
> nr_attempts = DEFAULT_TIMEOUT?

No :) @nr_attempts are cummulative value, this is done
for sake to vary @step_ms if needed.

	Cyrill


More information about the CRIU mailing list