Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp957543imm; Wed, 6 Jun 2018 08:22:08 -0700 (PDT) X-Google-Smtp-Source: ADUXVKICzLvv2ahVNeKapnyqcZKwhC4nmCTSIEyOlUsy3/YuoRvzvoeUvckVSIHpaDSdSoxL8EYR X-Received: by 2002:a17:902:24e:: with SMTP id 72-v6mr3588699plc.87.1528298528680; Wed, 06 Jun 2018 08:22:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528298528; cv=none; d=google.com; s=arc-20160816; b=sWk18x26LuiqY1XyBSCVunjNkV1CJrvj4tKHBUZt5XhIlCbqUKKO89X9SgvdDHZJEo tvItRPf8IH5bttvjhp3tQ/9Q36WVbhmzWnk4O27nrHX71SVE1IFEv/dsVpjle+KhZX0E 78US+FpM60slooO4wRjuB/zLMFDJuMSjyaedp2jG0C12MY/ONoK/iRvI0+kH5uV06J/m mZOnaoiMUN3CdMvEn6QiGj9kulKfBBpkeYMwi9ROWOteqW4Sw8uaiVBt0EG+IgLlfjd+ xcbTZ6esdhXln+sNmbLXkekUNyJJ/F0qURXOGTGWsGPiv3UZ4U94W36rXnxlRKyATSrK gDNg== 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:arc-authentication-results; bh=oje/JDdEE4VABR9urAg9TWt+gFySfj+b6kTGBAD59JE=; b=FkiA4nKvCHYcFqwSkGjFJp0YY1h+R5LHz353fRDWPhslgBtrfgTv2kyL5spVuHtIEI 5Ghux3D0pkCRXo2S70arpuO4LD2leAcvIszFiwPbdyF6BNsmqh1QUzO7qTbYXsQ+SrQF 6L/P2XxNX1ltQGiUrUVNUpTq9lSnAHrGiJiTMdKyo0kQ6qsernLcne1jchE+qQ2vEzzq 63NUQsm8I1pqPh3dGQLpUgDx1kdXelEwfjUrGqEiovrPud3gGWGBiTWKQvlZbw1g9OQw 3OdfETsZ9RISPKNHgLaaktILIHw3px/dfa2wcPDq9G6Rzx8fXce41WXP456YcTOdMPQ8 op/w== 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 x4-v6si48650292pfm.110.2018.06.06.08.21.54; Wed, 06 Jun 2018 08:22:08 -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 S1752224AbeFFPUG (ORCPT + 99 others); Wed, 6 Jun 2018 11:20:06 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:40899 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751957AbeFFPUF (ORCPT ); Wed, 6 Jun 2018 11:20:05 -0400 Received: by mail-wm0-f68.google.com with SMTP id n5-v6so12737554wmc.5 for ; Wed, 06 Jun 2018 08:20:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=oje/JDdEE4VABR9urAg9TWt+gFySfj+b6kTGBAD59JE=; b=SFEkezSuHR34fcmFqV2xd+20ZbviikVHeOvhiNWG+NOJ5YOzfB69B6AHyu2kC5nl5W TLQ90klVa9wIhhChzv9GlHJ74StiJ53Anw7HCJjBoinY4i8M6DrY3lwaQdLKcDAG9jeY R5H+RaiT0dMXcHprqX9uUBPraKHoAdLO7CajR/AR5Q5c0vI1DL3pGVVHJEkOZqs6xCXN PrRBLJ4N8bUUmnYLX3yAHDZQ5t1OlHG4R1Uh67P4gOBbMdC58dbBeHgUjrfy9AmRXQEk a2iDRil15Cou98dIIHgWr6/qtofmRO/gCZIQH8Q2y3UZ541BUYRObmGcvWQQmdsaO87u 7lGQ== X-Gm-Message-State: APt69E0h6nbFSxXv39PTEuqcpiYa64ICVSb3TqkU6tTIkfvxRLKbAHGG 74j2pT34FlISESDNnDGus6akfg== X-Received: by 2002:a1c:3ac6:: with SMTP id h189-v6mr2296513wma.64.1528298403660; Wed, 06 Jun 2018 08:20:03 -0700 (PDT) Received: from localhost.localdomain ([151.15.207.242]) by smtp.gmail.com with ESMTPSA id h12-v6sm1433547wmb.3.2018.06.06.08.20.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Jun 2018 08:20:02 -0700 (PDT) Date: Wed, 6 Jun 2018 17:20:00 +0200 From: Juri Lelli To: Quentin Perret Cc: Dietmar Eggemann , peterz@infradead.org, rjw@rjwysocki.net, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, mingo@redhat.com, morten.rasmussen@arm.com, chris.redpath@arm.com, patrick.bellasi@arm.com, valentin.schneider@arm.com, vincent.guittot@linaro.org, thara.gopinath@linaro.org, viresh.kumar@linaro.org, tkjos@google.com, joelaf@google.com, smuckle@google.com, adharmap@quicinc.com, skannan@quicinc.com, pkondeti@codeaurora.org, edubezval@gmail.com, srinivas.pandruvada@linux.intel.com, currojerez@riseup.net, javi.merino@kernel.org Subject: Re: [RFC PATCH v3 03/10] PM: Introduce an Energy Model management framework Message-ID: <20180606152000.GB15894@localhost.localdomain> References: <20180521142505.6522-1-quentin.perret@arm.com> <20180521142505.6522-4-quentin.perret@arm.com> <20180606143739.GF10870@e108498-lin.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180606143739.GF10870@e108498-lin.cambridge.arm.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/06/18 15:37, Quentin Perret wrote: > Hi Dietmar, > > On Wednesday 06 Jun 2018 at 15:12:15 (+0200), Dietmar Eggemann wrote: > > > +static void fd_update_cs_table(struct em_cs_table *cs_table, int cpu) > > > +{ > > > + unsigned long cmax = arch_scale_cpu_capacity(NULL, cpu); > > > + int max_cap_state = cs_table->nr_cap_states - 1; > > > + unsigned long fmax = cs_table->state[max_cap_state].frequency; > > > + int i; > > > + > > > + for (i = 0; i < cs_table->nr_cap_states; i++) > > > + cs_table->state[i].capacity = cmax * > > > + cs_table->state[i].frequency / fmax; > > > +} > > > > This has issues on a 32bit system. cs_table->state[i].capacity (unsigned > > long) overflows with the frequency values stored in Hz. > > Ah, thank you very much for pointing this out ! I haven't tried on a 32bit > machine yet, my bad. I'll fix that for v4. > > > > > Maybe something like this to cure it: > > > > diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c > > index 6ad53f1cf7e6..c13b3eb8bf35 100644 > > --- a/kernel/power/energy_model.c > > +++ b/kernel/power/energy_model.c > > @@ -144,9 +144,11 @@ static void fd_update_cs_table(struct em_cs_table *cs_table, int cpu) > > unsigned long fmax = cs_table->state[max_cap_state].frequency; > > int i; > > > > - for (i = 0; i < cs_table->nr_cap_states; i++) > > - cs_table->state[i].capacity = cmax * > > - cs_table->state[i].frequency / fmax; > > + for (i = 0; i < cs_table->nr_cap_states; i++) { > > + u64 val = (u64)cmax * cs_table->state[i].frequency; > > + do_div(val, fmax); > > + cs_table->state[i].capacity = (unsigned long)val; > > + } > > } > > Hmmm yes, that should work. > > > > > This brings me to another question. Let's say there are multiple users of > > the Energy Model in the system. Shouldn't the units of frequency and power > > not standardized, maybe Mhz and mW? > > The task scheduler doesn't care since it is only interested in power diffs > > but other user might do. > > So the good thing about specifying units is that we can probably assume > ranges on the values. If the power is in mW, assuming that we're talking > about a single CPU, it'll probably fit in 16 bits. 65W/core should be > a reasonable upper-bound ? > But there are also vendors who might not be happy with disclosing absolute > values ... These are sometimes considered sensitive and only relative > numbers are discussed publicly. Now, you can also argue that we already > have units specified in IPA for ex, and that it doesn't really matter if > a driver "lies" about the real value, as long as the ratios are correct. > And I guess that anyone can do measurement on the hardware and get those > values anyway. So specifying a unit (mW) for the power is probably a > good idea. Mmm, I remember we fought quite a bit while getting capacity-dmpis-mhz binding accepted, and one of the musts was that the values were going to be normalized. So, normalized power values again maybe? Best, - Juri