Re: [PATCH v2] sched/cputime: Resync steal time when guest & host lose sync

From: Rik van Riel
Date: Tue Aug 16 2016 - 21:55:07 EST


On Wed, 2016-08-17 at 09:16 +0800, Wanpeng Li wrote:
>Â
> @@ -694,6 +699,12 @@ static cputime_t get_vtime_delta(struct
> task_struct *tsk)
> Â unsigned long now = READ_ONCE(jiffies);
> Â cputime_t delta, other;
> Â
> + /*
> + Â* The interval returned by account_other_time() is NOT
> + Â* rounded down to the nearest jiffy, while the base
> + Â* interval it is subtracted from is. So the max cputime
> + Â* limit is required to avoid underflow.
> + Â*/
> Â delta = jiffies_to_cputime(now - tsk->vtime_snap);
> Â other = account_other_time(delta);
> Â WARN_ON_ONCE(tsk->vtime_snap_whence == VTIME_INACTIVE);

That comment makes sense in the context of the discussion
we have been having over the past few days, but could be
somewhat cryptic to someone looking at it 3 years from now.

How about something like the following?

/*
Â* Unlike tick based timing, vtime based timing never has lost
Â* ticks, and no need for steal time accounting to make up for
Â* lost ticks. Vtime accounts a rounded version of actual
Â* elapsed time. Limit account_other_time to prevent rounding
Â* errors from causing elapsed vtime to go negative.
Â*/

--Â
All Rights Reversed.

Attachment: signature.asc
Description: This is a digitally signed message part