Received: by 10.213.65.68 with SMTP id h4csp1216178imn; Wed, 21 Mar 2018 05:40:37 -0700 (PDT) X-Google-Smtp-Source: AG47ELvQ+XJaByd75i7TMiMIwjks2JRx4Yhb+1/T33QB0YtzuFjSk8vOZvOZ9JtrhsKkvDmONlXS X-Received: by 10.99.127.88 with SMTP id p24mr157989pgn.93.1521636037851; Wed, 21 Mar 2018 05:40:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521636037; cv=none; d=google.com; s=arc-20160816; b=kL6wXd5zpE0/i3rKEOYOmcC3E3lCjYWClPkXpo9cnnGlObXV45Hqai1LCfOiyKWvAj HMF2zXJcOi2/H+HFoqJl7A6eEoWyeAKEByUWAMIdje2RQAK5gWWiUh9raes1hqpjy7VK jcWFMt9FPKPzYFr47CrzqPV2urx8FbQ2kaE+Py/bzjnssSjlhrj4bDZNGQRYiNlO+kP8 0qYZDZ03vbyBGUfYlhGdxsTRmL89q6tJmUdhai3E0UTF3FBeN84P9wOhheeKIPsjxf+y yNpLR2iaydU4++nqhWiecenYYM0rebia7qYjwLG3L9vHx/Wiwd6auO2E9sH0H1i7B3vA hEcA== 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=1q0R0iv4VaKynwK23Ou8w7NS+/MdjYN6ev2Ly57oo80=; b=yNY9eJ97HbgFNC0aIEgJYfS8sjybRXVhDYqqqo4GMUSN7VpSIA4YFxUGqGdbNUgco2 94WFItDECtJqALnIIMVIBhApY2wo6PzBvSGTbb2h4SpjSDHj7yXcrIHSblokzhOtO793 wiKqqPmpuKHqkIoTeKVgYmGfgnNxGNnlb0h8I+MIrllgCfWoBKKRaSkflcoqxLonWXCM QAg7OmA8KGYobWJw37pboRFx6zh0ufSnX8BLpst871Zz+XZmOAZrH4A0Ks9KEHP9qCb1 xrkuMqox019XnTeJ08cUneP8VIPTGf09VQmANZMsbIyd3K8kr9xOn2Bx1MjNIl2Pr/d+ +yjw== 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 h10si2738095pgf.326.2018.03.21.05.40.21; Wed, 21 Mar 2018 05:40:37 -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 S1751889AbeCUMj1 (ORCPT + 99 others); Wed, 21 Mar 2018 08:39:27 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:52748 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751775AbeCUMj0 (ORCPT ); Wed, 21 Mar 2018 08:39:26 -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 3123C1529; Wed, 21 Mar 2018 05:39:26 -0700 (PDT) Received: from e110439-lin (e110439-lin.cambridge.arm.com [10.1.210.68]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A9E5C3F487; Wed, 21 Mar 2018 05:39:23 -0700 (PDT) Date: Wed, 21 Mar 2018 12:39:21 +0000 From: Patrick Bellasi To: Dietmar Eggemann Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Quentin Perret , Thara Gopinath , linux-pm@vger.kernel.org, Morten Rasmussen , Chris Redpath , Valentin Schneider , "Rafael J . Wysocki" , Greg Kroah-Hartman , Vincent Guittot , Viresh Kumar , Todd Kjos , Joel Fernandes Subject: Re: [RFC PATCH 4/6] sched/fair: Introduce an energy estimation helper function Message-ID: <20180321123921.GB13951@e110439-lin> References: <20180320094312.24081-1-dietmar.eggemann@arm.com> <20180320094312.24081-5-dietmar.eggemann@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180320094312.24081-5-dietmar.eggemann@arm.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 20-Mar 09:43, Dietmar Eggemann wrote: > From: Quentin Perret [...] > +static unsigned long compute_energy(struct task_struct *p, int dst_cpu) > +{ > + unsigned long util, fdom_max_util; > + struct capacity_state *cs; > + unsigned long energy = 0; > + struct freq_domain *fdom; > + int cpu; > + > + for_each_freq_domain(fdom) { > + fdom_max_util = 0; > + for_each_cpu_and(cpu, &(fdom->span), cpu_online_mask) { > + util = cpu_util_next(cpu, p, dst_cpu); Would be nice to find a way to cache all these util and reuse them below... even just to ensure data consistency between the "cs" computation and its usage... > + fdom_max_util = max(util, fdom_max_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(&(fdom->span)); > + cs = find_cap_state(cpu, fdom_max_util); ^^^^ The above code could theoretically return NULL, although likely EAS is completely disabled if em->nb_cap_states == 0, right? If that's the case then, in the previous function, you can certainly avoid the initialization of *cs and maybe also add an explicit: BUG_ON(em->nb_cap_states == 0); which helps even just as "in code documentation". But, I'm not sure if maintainers like BUG_ON in scheduler code :) > + > + /* > + * The energy consumed by each CPU is derived from the power ^ Should we make more explicit that this is just the "active" energy consumed? > + * it dissipates at the expected OPP and its percentage of > + * busy time. > + */ > + for_each_cpu_and(cpu, &(fdom->span), cpu_online_mask) { > + util = cpu_util_next(cpu, p, dst_cpu); > + energy += cs->power * util / cs->cap; > + } > + } nit-pick: empty line before return? > + return energy; > +} > + > /* > * select_task_rq_fair: Select target runqueue for the waking task in domains > * that have the 'sd_flag' flag set. In practice, this is SD_BALANCE_WAKE, > -- > 2.11.0 > -- #include Patrick Bellasi