Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7859279ybi; Mon, 22 Jul 2019 22:20:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqzgwaReWW8SfiRGya0VCH+ywJIjEZFdDhKTKjEIzqpkXSSXE/WqCFJDJw6xNWQjE0ZuqSjD X-Received: by 2002:a17:90a:ac11:: with SMTP id o17mr81669708pjq.134.1563859224033; Mon, 22 Jul 2019 22:20:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563859224; cv=none; d=google.com; s=arc-20160816; b=pI3KwDOale051BbPEP2tKfxtsH49x1lOeXd+MXsHxXnJdAMbaRrEzY1St+1HM3zdWN grqRCzb9cyQYq4pxeH73KL2U/zw6fdgpR61t10y+9aq3UGN4+cS1HYPltW7bNl4EhKoR 3uUjPEicvD4SJJQkkdnhaA3ALBilwYGtL1nUHjWLeTEyFsP8Y/OBzE5k4MwNYqyAQSDG MdagIIrKOhMlCRGV8hqnLrRL3G7vRxl/FkRU3lYur43h588iMkpx1zQsuSAjK9X/Axup BjjCRlRUKupOXgmqkqWcap5Vl37rbp9NA3h8jSpXdXxCvVbPeyeXiyu1cOS2meHsJqM2 eY3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=OGtQKQCt9khEkE8et59U9zQKandJb/SEJEAAfyIeOb4=; b=rDUdPt2CX+6Dy4NIzOEz8oQaL/jmDw+hBie1Vzs7Ob4icF3YHi2DWbgm2yJHqVeGcb WfFAyjCW06rhsYzFJOpNTxhz4xDzCbvDnKsO/3rJeoXK21nc1sbeeo2pZ/vMvyegQA5k oAnYmF8oaGXLUqNNjhyjmJ+MEKbXVFWjRpXxt+vCFoE/Yd/riZizk4yTkSD3tamh0UE7 AHCapVn8sK91X2JMR5VeWfjZyiMd6AfADUzoPAYLLO5DqmAWgXAiw5ovgAHd5eWTk8HF T1njSDSHrjqEShoKiGXA6Ql9iwjU3bLrySq31o08mEa613fb4+pEI/41MI1Q2R/h2ZpW KHLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=aHJnx8Iq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p19si10464685pfn.53.2019.07.22.22.20.07; Mon, 22 Jul 2019 22:20:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=aHJnx8Iq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730074AbfGVT4O (ORCPT + 99 others); Mon, 22 Jul 2019 15:56:14 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:38532 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729700AbfGVT4O (ORCPT ); Mon, 22 Jul 2019 15:56:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=OGtQKQCt9khEkE8et59U9zQKandJb/SEJEAAfyIeOb4=; b=aHJnx8Iqh/XfDZqqNQ6GJLyYI tfjoh1xVn33wxYQvWAZVI8WUPVBPClZQROz4SxMdJYtuctwG2nKiFc8X20XqUsJQYolgEGyU/+7S+ Ms4r6hT+aBIG5FQ5fEfPQR0EfgjvjpeBOqchoAzulewc8e0pg3NDtU220sZSw1NiDe7VTFYxtA3YC y8ilQjovM84gTUlCY8zU/2ggKMf1nqHDMjtnnIAYnq+dKnvPR1igpCWKAB67sO+dwpYZexK3SSseb 1MV8zMX6jfidtITgnDeeh10sLH39UtABcKnviMCCaY5GtDkLjwsdXDj9IzVAwQgMIHeGyjUkxdj7i 1V0EaXtdA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hpePo-0006rj-Iw; Mon, 22 Jul 2019 19:56:09 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id B4A49980C59; Mon, 22 Jul 2019 21:56:05 +0200 (CEST) Date: Mon, 22 Jul 2019 21:56:05 +0200 From: Peter Zijlstra To: Oleg Nesterov Cc: Ingo Molnar , Thomas Gleixner , Andrew Fox , Stephen Johnston , linux-kernel@vger.kernel.org, Linus Torvalds , Stanislaw Gruszka Subject: Re: [PATCH] sched/cputime: make scale_stime() more precise Message-ID: <20190722195605.GI6698@worktop.programming.kicks-ass.net> References: <20190718131834.GA22211@redhat.com> <20190719110349.GG3419@hirez.programming.kicks-ass.net> <20190719134727.GV3463@hirez.programming.kicks-ass.net> <20190719143742.GA32243@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190719143742.GA32243@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 19, 2019 at 04:37:42PM +0200, Oleg Nesterov wrote: > On 07/19, Peter Zijlstra wrote: > > But I'm still confused, since in the long run, it should still end up > > with a proportionally divided user/system, irrespective of some short > > term wobblies. > > Why? > > Yes, statistically the numbers are proportionally divided. This; due to the loss in precision the distribution is like a step function around the actual s:u ratio line, but on average it still is s:u. Even if it were a perfect function, we'd still see increments in stime even if the current program state never does syscalls, simply because it needs to stay on that s:u line. > but you will (probably) never see the real stime == 1000 && utime == 10000 > numbers if you watch incrementally. See, there are no 'real' stime and utime numbers. What we have are user and system samples -- tick based. If the tick lands in the kernel, we get a system sample, if the tick lands in userspace we get a user sample. What we do have is an accurate (ns) based runtime accounting, and we (re)construct stime and utime from this; we divide the total known runtime in stime and utime pro-rata. Sure, we take a shortcut, it wobbles a bit, but seriously, the samples are inaccurate anyway, so who bloody cares :-) You can construct a program that runs 99% in userspace but has all system samples. All you need to do is make sure you're in a system call when the tick lands. > Just in case... yes I know that these numbers can only "converge" to the > reality, only their sum is correct. But people complain. People always complain, just tell em to go pound sand :-)