Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753200AbbF2Sy7 (ORCPT ); Mon, 29 Jun 2015 14:54:59 -0400 Received: from g9t5008.houston.hp.com ([15.240.92.66]:52336 "EHLO g9t5008.houston.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751464AbbF2Syx (ORCPT ); Mon, 29 Jun 2015 14:54:53 -0400 Message-ID: <1435604090.21928.19.camel@j-VirtualBox> Subject: Re: [PATCH 1/1] cputime: Make the reported utime+stime correspond to the actual runtime. From: Jason Low To: Fredrik =?ISO-8859-1?Q?Markstr=F6m?= Cc: Peter Zijlstra , mingo@redhat.com, linux-kernel@vger.kernel.org, Rik van Riel , =?ISO-8859-1?Q?Fr=E9d=E9ric?= Weisbecker , jason.low2@hp.com Date: Mon, 29 Jun 2015 11:54:50 -0700 In-Reply-To: References: <1434099316-29749-1-git-send-email-fredrik.markstrom@gmail.com> <1434099316-29749-2-git-send-email-fredrik.markstrom@gmail.com> <1434104217.1495.74.camel@twins> <20150612110158.GA18673@twins.programming.kicks-ass.net> <20150629145837.GE3644@twins.programming.kicks-ass.net> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 8bit Mime-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1496 Lines: 45 On Mon, 2015-06-29 at 17:28 +0200, Fredrik Markström wrote: > Hello Peter, the locking part looks good, I don't have a strong > opinion on per task/signal lock vs global lock. > > But with the patch we still update prev->utime and prev->stime > independently, which was the original problem. But maybe the locking > and monoticity/sum issue should be addressed by two separate patches > since they are separate bugs ? > > The part I'm referring to is the change below from my original patch > (maybe without the WARN_ON:s ?): > > … > - cputime_advance(&prev->stime, stime); > - cputime_advance(&prev->utime, utime); > + if (stime < prev->stime) { > + stime = prev->stime; > + utime = rtime - stime; > + } else if (utime < prev->utime) { > + utime = prev->utime; > + stime = rtime - utime; > + } > + WARN_ON(stime < prev->stime); > + WARN_ON(utime < prev->utime); > + WARN_ON(stime + utime != rtime); How about substituting: prev->stime = max(prev->stime, stime); prev->utime = max(prev->utime, utime); with if (stime > prev->stime || utime > prev->utime) { prev->stime = stime; prev->utime = utime; } in Peter's patch? -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/