Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752087AbdF3OAG (ORCPT ); Fri, 30 Jun 2017 10:00:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37370 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751978AbdF3OAE (ORCPT ); Fri, 30 Jun 2017 10:00:04 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3BEEB81127 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=riel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3BEEB81127 Message-ID: <1498831200.6130.13.camel@redhat.com> Subject: Re: [tip:sched/core] sched/cputime: Refactor the cputime_adjust() code From: Rik van Riel To: mingo@kernel.org, fransklaver@gmail.com, hpa@zytor.com, fweisbec@gmail.com, torvalds@linux-foundation.org, tglx@linutronix.de, wanpeng.li@hotmail.com, linux-kernel@vger.kernel.org, garsilva@embeddedor.com, sgruszka@redhat.com, peterz@infradead.org, linux-tip-commits@vger.kernel.org Date: Fri, 30 Jun 2017 10:00:00 -0400 In-Reply-To: References: <20170629184128.GA5271@embeddedgus> Organization: Red Hat, Inc Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 30 Jun 2017 14:00:04 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 930 Lines: 40 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.