Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3784630pxv; Mon, 5 Jul 2021 05:46:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyveTLdl34H9Jy/PDqyw2NeETpP/DqVvPuDOwEAAQWHJQw6orC1lJqGifqR16d3Pu0QeC7V X-Received: by 2002:a92:c210:: with SMTP id j16mr10920616ilo.91.1625489167800; Mon, 05 Jul 2021 05:46:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625489167; cv=none; d=google.com; s=arc-20160816; b=PZE92TXf304A/BRi9rBMqBxuQ1IlqDGBlKSHO4jM6pJrThkRV2KafVdvcsVo2yqQFL hsKFRHY+4QD+Rl22R+CrxzGkl3D+jDUaFDhLXFsPrEUffc7RcWXbMNpWJMdlMTq54Jr4 STTvOwtC9QXJR4ESOU4AUNu1voFIxn3yQjJsg6yg8WH9KdeIatDMPvldH1Qsd3VJJZNV /32b95Yg6+EyAJN89YFvOj0qlorF996jCOo8sNFrplAogsfyWKOt4BqnjNaB6/nn+166 tctJ2tbLSp/sjoM58ygEHNjewCY1iEZyEbyoZ53SUcCj9aPLIm22PdUqIpPBZGBxg1X9 K4Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=/nzfhVKA+sFIG2We1bjP4lgsu1G1LHtyVcZIfmFp+OE=; b=CN2Aolf/aOq6CiTBxH0NgtBBWu3qoN+FJ+sSIrU9dzD8irKra6Npnqf69SmTSA4hFT +b4XIftIGMex/akA76tOX7h+rvG3QKs34za+r8JUEsqPoDHQfUi47FAUE8QhOzvaCNT1 F+SObtV92bpseVdvv5wCcgJz6/uiVVB7A8YXEF/KvCtCTd+GJKDxIkAWi6H4tTYvqRVV wvDciFwchuPU2poge1Ush2JndFu6JeC8iKYyvw8EgQeZYpiv1cjxrLbl14pLWV5uk9G8 MuSb6S5BsEL7R9fxHoLm0LUtS1ksgiXujuUMzvoAf3RaeLWM/RlNagZv2VHAdGflL7e7 OIFQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l1si16626289jad.100.2021.07.05.05.45.56; Mon, 05 Jul 2021 05:46:07 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231310AbhGEMrr (ORCPT + 99 others); Mon, 5 Jul 2021 08:47:47 -0400 Received: from foss.arm.com ([217.140.110.172]:45706 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230326AbhGEMrr (ORCPT ); Mon, 5 Jul 2021 08:47:47 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0A5641042; Mon, 5 Jul 2021 05:45:10 -0700 (PDT) Received: from [192.168.178.6] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7D1063F73B; Mon, 5 Jul 2021 05:45:07 -0700 (PDT) Subject: Re: [PATCH 2/3] PM: EM: Make em_cpu_energy() able to return bigger values To: Lukasz Luba , linux-kernel@vger.kernel.org Cc: Chris.Redpath@arm.com, morten.rasmussen@arm.com, qperret@google.com, linux-pm@vger.kernel.org, peterz@infradead.org, rjw@rjwysocki.net, viresh.kumar@linaro.org, vincent.guittot@linaro.org, mingo@redhat.com, juri.lelli@redhat.com, rostedt@goodmis.org, segall@google.com, mgorman@suse.de, bristot@redhat.com, CCj.Yeh@mediatek.com References: <20210625152603.25960-1-lukasz.luba@arm.com> <20210625152603.25960-3-lukasz.luba@arm.com> From: Dietmar Eggemann Message-ID: <266f4b52-62c5-48bc-2680-1f09b6eb90cc@arm.com> Date: Mon, 5 Jul 2021 14:44:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210625152603.25960-3-lukasz.luba@arm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 25/06/2021 17:26, Lukasz Luba wrote: > The Energy Model (EM) em_cpu_energy() is responsible for providing good > estimation regarding CPUs energy. It contains proper data structures which > are then used during calculation. The values stored in there are in > milli-Watts precision (or in abstract scale) smaller that 0xffff, which use I guess you refer to 'if (... || power > EM_MAX_POWER)' check in em_create_perf_table() [kernel/power/energy_model.c]. > sufficient unsigned long even on 32-bit machines. There are scenarios where ^^^^^^^^^ Can you describe these scenarios better with one example (EAS placement of an example task on a 2 PD system) which highlights the issue and how it this patch-set solves it? In this example you can list all the things which must be there to create a situation in EAS in which the patch-set helps. > we would like to provide calculated estimations in a better precision and > the values might be 1000 times bigger. This patch makes possible to use Where is this `1000` coming from? > quite big values for also 32-bit machines. > > Signed-off-by: Lukasz Luba > --- > include/linux/energy_model.h | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h > index 3f221dbf5f95..2016f5a706e0 100644 > --- a/include/linux/energy_model.h > +++ b/include/linux/energy_model.h > @@ -101,7 +101,7 @@ void em_dev_unregister_perf_domain(struct device *dev); > * Return: the sum of the energy consumed by the CPUs of the domain assuming > * a capacity state satisfying the max utilization of the domain. > */ > -static inline unsigned long em_cpu_energy(struct em_perf_domain *pd, > +static inline u64 em_cpu_energy(struct em_perf_domain *pd, > unsigned long max_util, unsigned long sum_util, > unsigned long allowed_cpu_cap) > { > @@ -180,7 +180,7 @@ static inline unsigned long em_cpu_energy(struct em_perf_domain *pd, > * pd_nrg = ------------------------ (4) > * scale_cpu > */ > - return ps->cost * sum_util / scale_cpu; > + return div_u64((u64)ps->cost * sum_util, scale_cpu); > } > > /** > @@ -217,7 +217,7 @@ static inline struct em_perf_domain *em_pd_get(struct device *dev) > { > return NULL; > } > -static inline unsigned long em_cpu_energy(struct em_perf_domain *pd, > +static inline u64 em_cpu_energy(struct em_perf_domain *pd, > unsigned long max_util, unsigned long sum_util, > unsigned long allowed_cpu_cap) > { >