From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751480AbdAYPZ0 (ORCPT ); Wed, 25 Jan 2017 10:25:26 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:34451 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750870AbdAYPZY (ORCPT ); Wed, 25 Jan 2017 10:25:24 -0500 Date: Wed, 25 Jan 2017 16:25:20 +0100 From: Frederic Weisbecker To: Martin Schwidefsky Cc: LKML , Tony Luck , Wanpeng Li , Peter Zijlstra , Michael Ellerman , Heiko Carstens , Benjamin Herrenschmidt , Thomas Gleixner , Paul Mackerras , Ingo Molnar , Fenghua Yu , Rik van Riel , Stanislaw Gruszka Subject: Re: [PATCH 37/37] s390: Prevent from cputime leaks Message-ID: <20170125152518.GA3302@lerouge> References: <1485109213-8561-1-git-send-email-fweisbec@gmail.com> <1485109213-8561-38-git-send-email-fweisbec@gmail.com> <20170123104456.74cb2ef3@mschwideX1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170123104456.74cb2ef3@mschwideX1> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 23, 2017 at 10:44:56AM +0100, Martin Schwidefsky wrote: > On Sun, 22 Jan 2017 19:20:13 +0100 > Frederic Weisbecker wrote: > > > The s390 clock has a higher granularity than nanoseconds. 1 nanosec > > equals 4.096 in s390 cputime_t. Therefore we leak a remainder while > > flushing the cputime through cputime_to_nsecs(). > > > > For more precision, make sure we keep that remainder on cputime > > accumulators for later accounting. > > > > Reported-by: Martin Schwidefsky > > Cc: Benjamin Herrenschmidt > > Cc: Paul Mackerras > > Cc: Michael Ellerman > > Cc: Heiko Carstens > > Cc: Martin Schwidefsky > > Cc: Tony Luck > > Cc: Fenghua Yu > > Cc: Peter Zijlstra > > Cc: Rik van Riel > > Cc: Thomas Gleixner > > Cc: Ingo Molnar > > Cc: Stanislaw Gruszka > > Cc: Wanpeng Li > > Signed-off-by: Frederic Weisbecker > > NAK. Good intention but the patch is just broken. with 36 of the 37 > patches applied all looks good but the last one completely breaks the > accounting for s390. This is from an idle system: > > top - 10:39:33 up 0 min, 1 user, load average: 0,00, 0,00, 0,00 > Tasks: 106 total, 1 running, 105 sleeping, 0 stopped, 0 zombie > %Cpu0 : 8,9 us, 21,6 sy, 0,0 ni, 0,0 id, 0,0 wa, 10,8 hi, 4,3 si, 54,4 st > %Cpu1 : 0,0 us, 23,5 sy, 0,0 ni, 0,0 id, 0,0 wa, 19,0 hi, 13,1 si, 44,3 st > %Cpu2 : 0,0 us, 30,3 sy, 0,0 ni, 0,0 id, 0,0 wa, 14,7 hi, 14,8 si, 40,2 st > KiB Mem : 1009304 total, 818808 free, 57284 used, 133212 buff/cache > KiB Swap: 1048556 total, 1048556 free, 0 used. 917356 avail Mem Oh ok. I must have done something wrong. > > There is another issue that affects precision, there is no s390 specific > version of cputime_to_nsecs. The generic version uses cputime_to_usecs > and mulitplies by 1000 to get nano-seconds. That already looses precision. That's right. And that's the point of this patch. I'm not sure we can have a more precise version of cputime_to_nsecs() if 1 nsec == 4.096 cputime_t > > For now just drop that last patch please. Ok, I'm leaving it apart. Thanks.