Received: by 10.192.165.148 with SMTP id m20csp355026imm; Fri, 20 Apr 2018 07:52:45 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+eygZyDV0qUR7minU4uUpe3ubtBl3Z5VywozibmqMjp1x3R+sqIP08BYNN/jL0mfPvqx/E X-Received: by 10.99.167.75 with SMTP id w11mr8766282pgo.351.1524235965035; Fri, 20 Apr 2018 07:52:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524235964; cv=none; d=google.com; s=arc-20160816; b=DcyNxHNGf9mpZLCHx/zSZ3A/XmXGikGglOM8xPoUwOWVIMYwyit7lwMRsboulKYzxY hfJ2bZii7UKzYG/nTbG1ydJinkF9g5Hfnr71+qPaa2Ta9O7Hqzgo8Am8rW+zFud4f2fE DEm4b/HOx9bD16Ioegj59BD+EqaAlIyGZP2Jc/Aj1YWWtRhwAaXI1eC8eh1kniflTqS+ cBvut8hDhiq6OVzUOyZ2ewSmLnKVoqf+hD0Hf5GdiYMRVhNAYGFIYy77GMgAmTcgY1w0 OSBhuPZZfXTDj9elKreAwZOg7O6DkdseAm4cfdO8Ah+97cxLmL7flJxRNajwAuaNkIjt +3Tw== 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=KGGzVJtaQ62uVjuIu/uwmJZKdQpcNWGagx+iH7e04iI=; b=Z6SVx37eoGtVd2USKCwj1MgkDSP3ZjgtLE35adFJHjhhNwfVboN0cg5ucrlvH4Dv8j UuSlsJoqs+eYnsqYNjJxku3adDzrFASn0cvn+z12zd/VzWJavPkeNUHb5pWVHowXqEVI Bf1iRPbADzamf8sdbblC5ULLRlVQ0sG5a6SG3DIskWuHt3SLx+rjHNVoyccF+BQsIaA0 uYqcrLeVTywMqqcR5fv++yABGnLgJBneuobZRVbNvbDjgkZ++vhdy2IUYtiOwle7MCN/ o3QETX7h7WpBNHnJfs/nt1QmYAGsMs2At0mB3FcmkA5JCHZrw3oilPZ0aquGDJTVqgam bMGg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v1si5624317pfg.222.2018.04.20.07.52.30; Fri, 20 Apr 2018 07:52:44 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755316AbeDTOv1 (ORCPT + 99 others); Fri, 20 Apr 2018 10:51:27 -0400 Received: from foss.arm.com ([217.140.101.70]:50044 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755191AbeDTOvZ (ORCPT ); Fri, 20 Apr 2018 10:51:25 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0B04080D; Fri, 20 Apr 2018 07:51:25 -0700 (PDT) Received: from e108498-lin.cambridge.arm.com (e108498-lin.cambridge.arm.com [10.1.210.84]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EA8B33F59D; Fri, 20 Apr 2018 07:51:21 -0700 (PDT) Date: Fri, 20 Apr 2018 15:51:20 +0100 From: Quentin Perret To: Leo Yan Cc: Dietmar Eggemann , linux-kernel@vger.kernel.org, Peter Zijlstra , Thara Gopinath , linux-pm@vger.kernel.org, Morten Rasmussen , Chris Redpath , Patrick Bellasi , Valentin Schneider , "Rafael J . Wysocki" , Greg Kroah-Hartman , Vincent Guittot , Viresh Kumar , Todd Kjos , Joel Fernandes , Juri Lelli , Steve Muckle , Eduardo Valentin Subject: Re: [RFC PATCH v2 4/6] sched/fair: Introduce an energy estimation helper function Message-ID: <20180420145120.GC14391@e108498-lin.cambridge.arm.com> References: <20180406153607.17815-1-dietmar.eggemann@arm.com> <20180406153607.17815-5-dietmar.eggemann@arm.com> <20180418092316.GB15682@leoy-ThinkPad-X240s> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180418092316.GB15682@leoy-ThinkPad-X240s> User-Agent: Mutt/1.8.3 (2017-05-23) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wednesday 18 Apr 2018 at 17:23:16 (+0800), Leo Yan wrote: > On Fri, Apr 06, 2018 at 04:36:05PM +0100, Dietmar Eggemann wrote: > > [...] > > > +/* > > + * Estimates the system level energy assuming that p wakes-up on dst_cpu. > > + * > > + * compute_energy() is safe to call only if an energy model is available for > > + * the platform, which is when sched_energy_enabled() is true. > > + */ > > +static unsigned long compute_energy(struct task_struct *p, int dst_cpu) > > +{ > > + unsigned long util, max_util, sum_util; > > + struct capacity_state *cs; > > + unsigned long energy = 0; > > + struct freq_domain *fd; > > + int cpu; > > + > > + for_each_freq_domain(fd) { > > + max_util = sum_util = 0; > > + for_each_cpu_and(cpu, freq_domain_span(fd), cpu_online_mask) { > > + util = cpu_util_next(cpu, p, dst_cpu); > > + util += cpu_util_dl(cpu_rq(cpu)); > > + max_util = max(util, max_util); > > + sum_util += util; > > + } > > + > > + /* > > + * Here we assume that the capacity states of CPUs belonging to > > + * the same frequency domains are shared. Hence, we look at the > > + * capacity state of the first CPU and re-use it for all. > > + */ > > + cpu = cpumask_first(freq_domain_span(fd)); > > + cs = find_cap_state(cpu, max_util); > > + energy += cs->power * sum_util / cs->cap; > > I am a bit worry about the resolution issue, especially when the > capacity value is a quite high value and sum_util is a minor value. Good point. As of now, the cs->power values happen to be in micro-watts for the platforms we've been testing with, so they're typically high enough to avoid significant resolution problem I guess. Now, the energy model code has to be reworked significantly as we have to remove the dependency on PM_OPP, so I'll try to make sure to keep this issue in mind for the next version. Thanks, Quentin