[Devel] [PATCH rh7] ve: Add interface for @start_timespec and @real_start_timespec adjustmen

Vladimir Davydov vdavydov at virtuozzo.com
Tue Feb 9 02:29:56 PST 2016


On Tue, Feb 09, 2016 at 01:12:42PM +0300, Cyrill Gorcunov wrote:
> On Tue, Feb 09, 2016 at 01:02:09PM +0300, Vladimir Davydov wrote:
> > On Mon, Feb 08, 2016 at 11:32:12AM +0300, Cyrill Gorcunov wrote:
> > > +static int ve_ts_read(struct cgroup *cg, struct cftype *cft, struct seq_file *m)
> > > +{
> > > +	struct ve_struct *ve = cgroup_ve(cg);
> > > +	struct timespec ts, *delta;
> > > +
> > > +	do_posix_clock_monotonic_gettime(&ts);
> > > +	if (cft->private == VE_CF_START_TIMESPEC) {
> > > +		delta = &ve->start_timespec;
> > > +	} else if (cft->private == VE_CF_REAL_START_TIMESPEC) {
> > > +		delta = &ve->real_start_timespec;
> > > +		monotonic_to_bootbased(&ts);
> > > +	} else {
> > > +		delta = &ts;
> > > +		memset(&ts, 0, sizeof(ts));
> > > +		WARN_ON_ONCE(1);
> > > +	}
> > > +
> > > +	set_normalized_timespec(&ts, ts.tv_sec - delta->tv_sec,
> > > +				ts.tv_nsec - delta->tv_nsec);
> > > +	seq_printf(m, "%ld %ld", ts.tv_sec, ts.tv_nsec);
> > > +	return 0;
> > > +}
> > 
> > So the output of ve.start_timespec is going to evolve over time, right?
> 
> Yes. We take current values then substract the @real_[start_]timespec
> and return it. IOW they are just monotonic|boottime clocks.

Then I think we should name these files accordingly to avoid confusion.
ve.clock_{monotonic,boottime} probably.

> 
> > This looks weird to me. Wouldn't it be better if we returned the
> > timespec as is?
> 
> No, we have to account real total_sleep_time the container
> has on the node, because when you close the lid the total
> sleep time will increse but @real_start_timespec won't
> as far as I can say and this gonna be wrong.
> 

But you can always calculate the difference in userspace, like
(CLOCK_BOOTTIME - ve.real_start_timespec), no?


More information about the Devel mailing list