Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752133AbdF3Olx (ORCPT ); Fri, 30 Jun 2017 10:41:53 -0400 Received: from mail-vk0-f65.google.com ([209.85.213.65]:35611 "EHLO mail-vk0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751675AbdF3Olv (ORCPT ); Fri, 30 Jun 2017 10:41:51 -0400 MIME-Version: 1.0 In-Reply-To: <1498831200.6130.13.camel@redhat.com> References: <20170629184128.GA5271@embeddedgus> <1498831200.6130.13.camel@redhat.com> From: Frans Klaver Date: Fri, 30 Jun 2017 16:41:50 +0200 Message-ID: Subject: Re: [tip:sched/core] sched/cputime: Refactor the cputime_adjust() code To: Rik van Riel Cc: Ingo Molnar , hpa@zytor.com, Frederic Weisbecker , torvalds@linux-foundation.org, Thomas Gleixner , wanpeng.li@hotmail.com, "linux-kernel@vger.kernel.org" , "Gustavo A. R. Silva" , sgruszka@redhat.com, Peter Zijlstra , linux-tip-commits@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1175 Lines: 39 On Fri, Jun 30, 2017 at 4:00 PM, Rik van Riel wrote: > 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. The first time utime is used after that assignment, it is overwritten with rtime - stime. The utime = rtime assignment is then pointless.