Re: [tip:sched/core] sched/cputime: Refactor the cputime_adjust() code

From: Rik van Riel
Date: Fri Jun 30 2017 - 10:00:19 EST


On Fri, 2017-06-30 at 06:10 -0700, tip-bot for Gustavo A. R. Silva
wrote:

> +++ b/kernel/sched/cputime.c
> @@ -615,19 +615,13 @@ static void cputime_adjust(struct task_cputime
> *curr,
> Â Â* userspace. Once a task gets some ticks, the monotonicy
> code at
> Â Â* 'update' will ensure things converge to the observed
> ratio.
> Â Â*/
> - if (stime == 0) {
> - utime = rtime;
> - goto update;
> + if (stime != 0) {
> + if (utime == 0)
> + stime = rtime;
> + else
> + stime = scale_stime(stime, rtime, stime +
> utime);
> Â }
> Â
> - if (utime == 0) {
> - stime = rtime;
> - goto update;
> - }
> -
> - stime = scale_stime(stime, rtime, stime + utime);
> -
> -update:

Wait, what?

This get rid of the utime = rtime assignment, when
stime == 0. That could be a correctness issue.

> Â /*
> Â Â* Make sure stime doesn't go backwards; this preserves
> monotonicity
> Â Â* for utime because rtime is monotonic.