Re: [PATCH v5 3/3] sched/cputime: Add steal time support to full dynticks CPU time accounting

From: Rik van Riel
Date: Wed Jun 08 2016 - 15:05:11 EST


On Wed, 2016-06-08 at 11:05 +0800, Wanpeng Li wrote:
>Â
> @@ -681,12 +681,17 @@ static cputime_t vtime_delta(struct task_struct
> *tsk)
> Âstatic cputime_t get_vtime_delta(struct task_struct *tsk)
> Â{
> Â unsigned long now = READ_ONCE(jiffies);
> - unsigned long delta = now - tsk->vtime_snap;
> + cputime_t delta_time, steal_time;
> Â
> + steal_time =
> jiffies_to_cputime(steal_account_process_tick());
> + delta_time = jiffies_to_cputime(now - tsk->vtime_snap);
> Â WARN_ON_ONCE(tsk->vtime_snap_whence == VTIME_INACTIVE);
> Â tsk->vtime_snap = now;
> Â
> - return jiffies_to_cputime(delta);
> + if (steal_time < delta_time)
> + delta_time -= steal_time;
> +
> + return delta_time;
> Â}

This isn't right.

If steal_time is equal to or larger than delta_time,
get_vtime_delta needs to return 0, not delta_time.

Otherwise the same time will be counted twice.

--
All rights reversed

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