Received: by 2002:aa6:da0e:0:b029:115:a171:fe4c with SMTP id z14csp1266863lkb; Wed, 7 Jul 2021 03:00:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNQ2Pb0u71UKLhJOtcruVFSZftGzayEZjjUi8DCKid8bWyfwqOzq3AZkK1QBKY2ckMuyQQ X-Received: by 2002:a17:906:4f91:: with SMTP id o17mr23368615eju.219.1625652002403; Wed, 07 Jul 2021 03:00:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625652002; cv=none; d=google.com; s=arc-20160816; b=Wz5fHMf+6mUaVuGkPJH/cBUWosIzgl9Lzukqp0im229AUtXMloN4Nj0nf4WNG7smsU 7It/+LfjDpdqbFUpHhJJcUdmk5egvMsGYyMw6oAycEVsTYir1Hxrt4dPQJLRknpmWVuf 9MWT/Bch6mxUj+uzynD928zVVIYieUlVrjCJ+XB+EfxyUhS8cIfc51RQUjt4FpozKThw knTYgOJvOhjB7vMY6hwIIpy26pGWz645sNjjzo8yQ3FjmSXY2Q5dywGy61XZtUISjuCS oKvm1iOjfo6aBm/L2ttzD/Nhq7GWeotHjKw5zVn8fCl0An3t89eSUWUAftA+ov/1XKQF BbCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=kGW/nRoBu30tv7Ct47L5ywv9N9fYBMZBlHQ91yDyhbU=; b=ugW1NWF1LJ90V3CKIYNqpdc0ztRrGNYHXj4Esy9fesiP+ntgHifslEpf3ys8JRKJat MH1snCqeU7EjrZnYDK6maM/FX4UJSKOw2hynN2aUVLaN6fZ4To7YOHtBdXZoqO06AJtK /A7UNt5i+dYjPsolo8UdISgcPqfZ7QunaYUbkTKQI4Zs6W5t4qrgMAsX//RlfXzx5PeD C5khsq2XspqwxQeU6JQW4tH1ISBGMtKl5SoXAz7Licz8aVSa+dbR0OK652c5MIylCfLH d5ifvz/yEziG9bXYz7XfMxIjeKh6wO/zpw2d3/xPXxr+9k8mVr3E/S5q+45S116UtgZL B7fQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Upf4p/aS"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jz26si16974211ejc.747.2021.07.07.02.59.39; Wed, 07 Jul 2021 03:00:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Upf4p/aS"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230150AbhGGJ7Q (ORCPT + 99 others); Wed, 7 Jul 2021 05:59:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231426AbhGGJ7N (ORCPT ); Wed, 7 Jul 2021 05:59:13 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A936C061574 for ; Wed, 7 Jul 2021 02:56:33 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id p21so3003118lfj.13 for ; Wed, 07 Jul 2021 02:56:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kGW/nRoBu30tv7Ct47L5ywv9N9fYBMZBlHQ91yDyhbU=; b=Upf4p/aSFZlDnJglzlRV11YYUdXG1aXaYnzKeQzZIss5zA2u7SfVkTDcVKkDakIamk 3hz/8kIuICcyAtvWcMQzs/+gcUuEsCGs35lchhqOnlVssZQyBP3NYNb4JxzCcknwoSmq YVXVpIdsnm70UFLYK3Jzz32MJSJwLHzzX7ENAxvNFX6jS48HbOq8c+tAx1gdmEi23CoS c2P7F+Yl4uyTAM/GjyGBtSGe1wy+wWu+1krKKo0433g4WIq/IWyws7lDwm9JyMSZzlka Crsv32GQiwI3CbQxFj9ThpqX69OtCisokCdxd/chNGQ2BUtzHEPNgnWxzmCltAosvpFo 9Omw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kGW/nRoBu30tv7Ct47L5ywv9N9fYBMZBlHQ91yDyhbU=; b=qpi3kF918IAJP6GYhXYYfAbGp27vEiFDwbsrMNkcSk93n1X9clXxpHk775qfbUcnqF 1mJWeva0vI4BZkZhSGew+2xXMoxy2kCMBkAES7N3FfMRDyas4Jr9dnRnLtvb2g3xc0/w sriYf0tHU/se64VvitN7kQWTZhJjs/Kh4vxLE1RlIjpt9uw2tIDUpTfPTWMUF3J3jb1H Dd5FMilzOyk/bjL6sjfMMmHipMp9CKwHQQRgBf9Ymkz7m2FA1uGBrLt+moTtqHmGndhe 1HvUTtSY6a5eE7Fi1lMUI8lZDTi+uSzTNN64wWB5+AxGC2//BfliBSSVeYVvv9kxKgM5 EpvA== X-Gm-Message-State: AOAM532WcYzSuqOuQoJvdFlGWSXvUe4YlzCuprVFL7lhwBkEjmNbZann PNxJC7UxpuA2MUk3eEsbmuM5MNReQtRNPhvDs9u2Iw== X-Received: by 2002:a19:505a:: with SMTP id z26mr17355505lfj.470.1625651791931; Wed, 07 Jul 2021 02:56:31 -0700 (PDT) MIME-Version: 1.0 References: <20210625152603.25960-1-lukasz.luba@arm.com> <20210625152603.25960-2-lukasz.luba@arm.com> <2f43b211-da86-9d48-4e41-1c63359865bb@arm.com> <297df159-1681-f0a7-843d-f34d86e51d4c@arm.com> In-Reply-To: <297df159-1681-f0a7-843d-f34d86e51d4c@arm.com> From: Vincent Guittot Date: Wed, 7 Jul 2021 11:56:20 +0200 Message-ID: Subject: Re: [PATCH 1/3] sched/fair: Prepare variables for increased precision of EAS estimated energy To: Lukasz Luba Cc: linux-kernel , Chris Redpath , Dietmar Eggemann , Morten Rasmussen , Quentin Perret , "open list:THERMAL" , Peter Zijlstra , "Rafael J. Wysocki" , Viresh Kumar , Ingo Molnar , Juri Lelli , Steven Rostedt , segall@google.com, Mel Gorman , Daniel Bristot de Oliveira , CCj.Yeh@mediatek.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 7 Jul 2021 at 11:48, Lukasz Luba wrote: > > > > On 7/7/21 10:37 AM, Vincent Guittot wrote: > > On Wed, 7 Jul 2021 at 10:23, Lukasz Luba wrote: > >> > >> > >> > >> On 7/7/21 9:00 AM, Vincent Guittot wrote: > >>> On Wed, 7 Jul 2021 at 09:49, Lukasz Luba wrote: > >>>> > >>>> > >>>> > >>>> On 7/7/21 8:07 AM, Vincent Guittot wrote: > >>>>> On Fri, 25 Jun 2021 at 17:26, Lukasz Luba wrote: > >>>>>> > >>>>>> The Energy Aware Scheduler (EAS) tries to find best CPU for a waking up > >>>>>> task. It probes many possibilities and compares the estimated energy values > >>>>>> for different scenarios. For calculating those energy values it relies on > >>>>>> Energy Model (EM) data and em_cpu_energy(). The precision which is used in > >>>>>> EM data is in milli-Watts (or abstract scale), which sometimes is not > >>>>>> sufficient. In some cases it might happen that two CPUs from different > >>>>>> Performance Domains (PDs) get the same calculated value for a given task > >>>>>> placement, but in more precised scale, they might differ. This rounding > >>>>>> error has to be addressed. This patch prepares EAS code for better > >>>>>> precision in the coming EM improvements. > >>>>> > >>>>> Could you explain why 32bits results are not enough and you need to > >>>>> move to 64bits ? > >>>>> > >>>>> Right now the result is in the range [0..2^32[ mW. If you need more > >>>>> precision and you want to return uW instead, you will have a result in > >>>>> the range [0..4kW[ which seems to be still enough > >>>>> > >>>> > >>>> Currently we have the max value limit for 'power' in EM which is > >>>> EM_MAX_POWER 0xffff (64k - 1). We allow to register such big power > >>>> values ~64k mW (~64Watts) for an OPP. Then based on 'power' we > >>>> pre-calculate 'cost' fields: > >>>> cost[i] = power[i] * freq_max / freq[i] > >>>> So, for max freq the cost == power. Let's use that in the example. > >>>> > >>>> Then the em_cpu_energy() calculates as follow: > >>>> cost * sum_util / scale_cpu > >>>> We are interested in the first part - the value of multiplication. > >>> > >>> But all these are internal computations of the energy model. At the > >>> end, the computed energy that is returned by compute_energy() and > >>> em_cpu_energy(), fits in a long > >> > >> Let's take a look at existing *10000 precision for x CPUs: > >> cost * sum_util / scale_cpu = > >> (64k *10000) * (x * 800) / 1024 > >> which is: > >> x * ~500mln > >> > >> So to be close to overflowing u32 the 'x' has to be > (?=) 8 > >> (depends on sum_util). > > > > Sorry but I don't get your point. > > This patch is about the return type of compute_energy() and > > em_cpu_energy(). And even if we decide to return uW instead of mW, > > there is still a lot of margin. > > > > It's not because you need u64 for computing intermediate value that > > you must returns u64 > > The example above shows the need of u64 return value for platforms > which are: > - 32bit > - have e.g. 16 CPUs > - has big power value e.g. ~64k mW > Then let's to the calc: > (64k * 10000) * (16 * 800) / 1024 = ~8000mln = ~8bln so you return a power consumption of 8kW !!! > > The returned value after applying the whole patch set > won't fit in u32 for such cluster. > > We might make *assumption* that the 32bit platforms will not > have bigger number of CPUs in the cluster or won't report > big power values. But I didn't wanted to make such assumption. > >