Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3705354ybi; Fri, 19 Jul 2019 07:39:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqy5TdNAUiNb5CrCDDKfz8qyBzZY83/lj0p+CUuaSVF5eAp0P9FSE9yO05V3MWklVZfFXRXk X-Received: by 2002:a17:902:9307:: with SMTP id bc7mr55643039plb.183.1563547166336; Fri, 19 Jul 2019 07:39:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563547166; cv=none; d=google.com; s=arc-20160816; b=gObdblp1cT5X00/17zRZeT/NRD0T2w14gPwpzflLzHkID9BGEzcWY/KlzJMQLliTCE xWgq9ePc6RiWmVOpvZpaWj4MrBiegO/i3u6uJDVxE3NXW74yHo7mRcRP5wiba+Lw3zAb dkglX8agNdS/rqOSKoaa1l4wTF0BxRKLdj8vEkKn4R6OYpTvOAzgFNCx2hpE7blgO/r8 bPmM9vd3Hs2wWj99RRwGteIvDQqslW5Vd67w9tSTqFUWMZ07jC++zjbVUZpdbp5GKaq+ 72LvPXEMJhYNYCF/JqqzneQgy3maV1lBiNYU+iPT3RqT8xqKIDK85sz/mlkCKE34JZ0S D+6g== 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; bh=5ilytTbmI0tCkRGxTyqE0Wb6ldsGqWh4+ALGjzSzzO0=; b=mBxdw3fYwtQ2JXn4/f2qJ0uF+aYQyzicTY9CiA/vdHPZjn5zFXoprQ95JExsjA2xOX V1mrcNp19nCuadELBwxtr8GrH7PSVZOr2jC1q0vPKQqc5egPTnc8e3Cdqq3rCyjH0V+2 pV7xYUIwAPeFb4uI6qeBSDmvxZyllgYAPZiqE1mw80pl/2oDZeqeU5OaMB7xK/5+y4P2 GUtHCL9IVGwQxWPR0yFN/toQ6HJCcspS0tEpGWU0t/FU5gnTnEzOPBz006VYYFXlteLs HOymZqmkVvVCg6UUzVlNLDI/DnvKzzlizuZSE9A1cZN4E6DzZtChzjegqCM49m3mSPAM bqxQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x32si131819pld.252.2019.07.19.07.39.11; Fri, 19 Jul 2019 07:39:26 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729747AbfGSOhu (ORCPT + 99 others); Fri, 19 Jul 2019 10:37:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52476 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729238AbfGSOhr (ORCPT ); Fri, 19 Jul 2019 10:37:47 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1E40D30860CC; Fri, 19 Jul 2019 14:37:47 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.43.17.136]) by smtp.corp.redhat.com (Postfix) with SMTP id 5D35957984; Fri, 19 Jul 2019 14:37:43 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Fri, 19 Jul 2019 16:37:46 +0200 (CEST) Date: Fri, 19 Jul 2019 16:37:42 +0200 From: Oleg Nesterov To: Peter Zijlstra 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: <20190719143742.GA32243@redhat.com> References: <20190718131834.GA22211@redhat.com> <20190719110349.GG3419@hirez.programming.kicks-ass.net> <20190719134727.GV3463@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190719134727.GV3463@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Fri, 19 Jul 2019 14:37:47 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/19, Peter Zijlstra wrote: > > > > $ ./stime 300000 > > > start=300000000000000 > > > ut(diff)/st(diff): 299994875 ( 0) 300009124 (2000) > > > ut(diff)/st(diff): 299994875 ( 0) 300011124 (2000) > > > ut(diff)/st(diff): 299994875 ( 0) 300013124 (2000) > > > ut(diff)/st(diff): 299994875 ( 0) 300015124 (2000) > > > ut(diff)/st(diff): 299994875 ( 0) 300017124 (2000) > > > ut(diff)/st(diff): 299994875 ( 0) 300019124 (2000) > > > ut(diff)/st(diff): 299994875 ( 0) 300021124 (2000) > > > ut(diff)/st(diff): 299994875 ( 0) 300023124 (2000) > > > ut(diff)/st(diff): 299994875 ( 0) 300025124 (2000) > > > ut(diff)/st(diff): 299994875 ( 0) 300027124 (2000) > > > ut(diff)/st(diff): 299994875 ( 0) 300029124 (2000) > > > ut(diff)/st(diff): 299996875 (2000) 300029124 ( 0) > > > ut(diff)/st(diff): 299998875 (2000) 300029124 ( 0) > > > ut(diff)/st(diff): 300000875 (2000) 300029124 ( 0) > > > ut(diff)/st(diff): 300002875 (2000) 300029124 ( 0) > > > ut(diff)/st(diff): 300004875 (2000) 300029124 ( 0) > > > ut(diff)/st(diff): 300006875 (2000) 300029124 ( 0) > > > ut(diff)/st(diff): 300008875 (2000) 300029124 ( 0) > > > ut(diff)/st(diff): 300010875 (2000) 300029124 ( 0) > > > ut(diff)/st(diff): 300012055 (1180) 300029944 ( 820) > > > ut(diff)/st(diff): 300012055 ( 0) 300031944 (2000) > > > ut(diff)/st(diff): 300012055 ( 0) 300033944 (2000) > > > ut(diff)/st(diff): 300012055 ( 0) 300035944 (2000) > > > ut(diff)/st(diff): 300012055 ( 0) 300037944 (2000) > > > > > > shows the problem even when sum_exec_runtime is not that big: 300000 secs. > > > > > > The new implementation of scale_stime() does the additional div64_u64_rem() > > > in a loop but see the comment, as long it is used by cputime_adjust() this > > > can happen only once. > > > > That only shows something after long long staring :/ There's no words on > > what the output actually means or what would've been expected. > > > > Also, your example is incomplete; the below is a test for scale_stime(); > > from this we can see that the division results in too large a number, > > but, important for our use-case in cputime_adjust(), it is a step > > function (due to loss in precision) and for every plateau we shift > > runtime into the wrong bucket. > > 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. but you will (probably) never see the real stime == 1000 && utime == 10000 numbers if you watch incrementally. Just in case... yes I know that these numbers can only "converge" to the reality, only their sum is correct. But people complain. Oleg.