Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752086AbbFLLCG (ORCPT ); Fri, 12 Jun 2015 07:02:06 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:50501 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750893AbbFLLCE (ORCPT ); Fri, 12 Jun 2015 07:02:04 -0400 Date: Fri, 12 Jun 2015 13:01:58 +0200 From: Peter Zijlstra To: Fredrik Markstrom Cc: mingo@redhat.com, linux-kernel@vger.kernel.org, Rik van Riel Subject: Re: [PATCH 1/1] cputime: Make the reported utime+stime correspond to the actual runtime. Message-ID: <20150612110158.GA18673@twins.programming.kicks-ass.net> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1434104217.1495.74.camel@twins> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1323 Lines: 39 On Fri, Jun 12, 2015 at 12:16:57PM +0200, Peter Zijlstra wrote: > On Fri, 2015-06-12 at 10:55 +0200, Fredrik Markstrom wrote: > > The scaling mechanism might sometimes cause top to report >100% > > (sometimes > 1000%) cpu usage for a single thread. This patch makes > > sure that stime+utime corresponds to the actual runtime of the thread. > > This Changelog is inadequate, it does not explain the actual problem. > > > +static DEFINE_SPINLOCK(prev_time_lock); > > global (spin)locks are bad. Since you have a proglet handy to test this; does something like the below help anything? --- kernel/sched/cputime.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c index f5a64ffad176..3d3f60a555a0 100644 --- a/kernel/sched/cputime.c +++ b/kernel/sched/cputime.c @@ -613,6 +613,10 @@ static void cputime_adjust(struct task_cputime *curr, stime = scale_stime((__force u64)stime, (__force u64)rtime, (__force u64)total); + + if (stime < prev->stime) + stime = prev->stime; + utime = rtime - stime; } -- 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/