Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751370AbcCFLAZ (ORCPT ); Sun, 6 Mar 2016 06:00:25 -0500 Received: from www.linutronix.de ([62.245.132.108]:41420 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751203AbcCFLAY (ORCPT ); Sun, 6 Mar 2016 06:00:24 -0500 Date: Sun, 6 Mar 2016 11:58:57 +0100 (CET) From: Thomas Gleixner To: Chris Friesen cc: Frederic Weisbecker , John Stultz , Daniel Lezcano , lkml , Peter Zijlstra , Ingo Molnar , Rik van Riel Subject: Re: [PATCH v2] sched/cputime: steal_account_process_tick() should return jiffies In-Reply-To: <56DBBDB8.40305@mail.usask.ca> Message-ID: References: <56DA1339.5030601@mail.usask.ca> <20160305131856.GA4441@lerouge> <56DBAF6D.5010503@mail.usask.ca> <56DBBDB8.40305@mail.usask.ca> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001,URIBL_BLOCKED=0.001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 934 Lines: 23 On Sat, 5 Mar 2016, Chris Friesen wrote: > The callers of steal_account_process_tick() expect it to return > whether a jiffy should be considered stolen or not. > > Currently the return value of steal_account_process_tick() is in > units of cputime, which vary between either jiffies or nsecs > depending on CONFIG_VIRT_CPU_ACCOUNTING_GEN. > > If cputime has nsecs granularity and there is a tiny amount of > stolen time (a few nsecs, say) then we will consider the entire > tick stolen and will not account the tick on user/system/idle, > causing /proc/stats to show invalid data. > > The fix is to change steal_account_process_tick() to accumulate > the stolen time and only account it once it's worth a jiffy. > > (Thanks to Frederic Weisbecker for suggestions to fix a bug in my > first version of the patch.) > > Signed-off-by: Chris Friesen Reviewed-by: Thomas Gleixner