Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7009761ybi; Mon, 22 Jul 2019 05:37:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqzbjSOgA6PKLNytkp2l2/atsa2wk1A5FOeD8Q2NEgp30anJr5AVlZD2p7yExWhRIU+duRNu X-Received: by 2002:a17:902:204:: with SMTP id 4mr73569700plc.178.1563799062173; Mon, 22 Jul 2019 05:37:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563799062; cv=none; d=google.com; s=arc-20160816; b=bJkEuzJ5W3Jipv+43tQISYvscNKtSYa4FUGoZc6C9CTTFdtCfTD9qGjfQUF6EZjZsE MCX4S0DdEcoQY+YtlElQc/cxyjlGEt87Ywj4GfFFGMtAlNymiBQkEIa/H9LD/80nSJ+O PBiEq3l8eupF93oBuVXIU9nvDphhRXn0b7905SYuWPN64GWKiCstXfA//05t5jNFU+1T avxKe8K8XMyrMFFX9BF9ESJH8diYCe0OtV2BIz9es7T6ZX45zDJpFO+NuqOjxb8LTsg2 8hc6l45zR2VatALaW+fnvELicKa3miAptALwy6dI6mpF3a2KbaVtDcL3OVe89FnpqRTj rIhg== 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=BC5XgvivldsnC6i6fz5N9I53G8TPypcmBoaJX2kXDFY=; b=Y1rRvVvcwgbC9vRHKqhhuusE3lcO4c76ckk+m+7Bqj+ORqLeVMRFHjR2OO23oA3ecB SLx+ut3Sbwmw5jjQfNHiAmWacSojsMmWsaqFKw9c7UQjcN8TkzBlzIaldUCEzT5rTzeD B1o7qaC1ZksvPZunRGEpH/fugnnHmu4N9bqfQ4/Y5G6NEH54CylkhusuoSKRwwJtqxjv YrpRAg+DA7A4s4u3ucwbJEJGUKDPiBs5JMnXdvpOK/Y6DzkvhMZHzRG1QP9yaWqfO3XS H+UmZSuUkUv7twT+dUoxHhsN7XwtRWKzcJKmDA5FQk1wRMSgCd0WtD6e43ypLutbjwZH tvMg== 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 e23si9374760pgn.595.2019.07.22.05.37.25; Mon, 22 Jul 2019 05:37:42 -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 S1729749AbfGVKwq (ORCPT + 99 others); Mon, 22 Jul 2019 06:52:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33862 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728317AbfGVKwp (ORCPT ); Mon, 22 Jul 2019 06:52:45 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8A766307D914; Mon, 22 Jul 2019 10:52:45 +0000 (UTC) Received: from localhost (unknown [10.43.2.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id E31905D9D3; Mon, 22 Jul 2019 10:52:42 +0000 (UTC) Date: Mon, 22 Jul 2019 12:52:41 +0200 From: Stanislaw Gruszka To: Peter Zijlstra Cc: Oleg Nesterov , Ingo Molnar , Thomas Gleixner , Andrew Fox , Stephen Johnston , linux-kernel@vger.kernel.org, Linus Torvalds Subject: Re: [PATCH] sched/cputime: make scale_stime() more precise Message-ID: <20190722105240.GA27219@redhat.com> References: <20190718131834.GA22211@redhat.com> <20190719110349.GG3419@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190719110349.GG3419@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Mon, 22 Jul 2019 10:52:45 +0000 (UTC) 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 01:03:49PM +0200, Peter Zijlstra wrote: > > 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. > > Your proposed function works; but is atrocious, esp. on 32bit. That > said, before we 'fixed' it, it had similar horrible divisions in, see > commit 55eaa7c1f511 ("sched: Avoid cputime scaling overflow"). > > Included below is also an x86_64 implementation in 2 instructions. > > I'm still trying see if there's anything saner we can do... I was always proponent of removing scaling and export raw values and sum_exec_runtime. But that has obvious drawback, reintroduce 'top hiding' issue. But maybe we can export raw values in separate file i.e. /proc/[pid]/raw_cpu_times ? So applications that require more precise cputime values for very long-living processes can use this file. Stanislaw