Received: by 10.213.65.68 with SMTP id h4csp4229990imn; Tue, 10 Apr 2018 11:18:48 -0700 (PDT) X-Google-Smtp-Source: AIpwx48bGehqNOyQQLzRBNHMj03OwV6hy6oIw4xBj2XKK9hmbxFINgAPERZjXG+evbFBc76EP8St X-Received: by 2002:a17:902:6a10:: with SMTP id m16-v6mr1479464plk.370.1523384328077; Tue, 10 Apr 2018 11:18:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523384328; cv=none; d=google.com; s=arc-20160816; b=MNMxO1iNTWN0ppoTACjFb7Z27pab9wU9xK+HDhjFRijj2ZjPsEgT8E6nb25UCLXwym TTn9aqTwTfafD+r7aTJN2Sxisw8CMthZrRqMCGCsgRKxHxibpvlL90vReWWdsGHNfrY7 5leEpgtM8CzN4SgTmQQ95I0LtylH5GOJvIHuxTFI8czdHSwowenOiYpkhtzbmzc9lizK LbwhJ4Yt7vPZvctJsbNDSkEn0pDwu5ipN7To4v45d+hQMOMxOtl73lO91QN8LlGVe8zA fsq8BljATXw4bmzYGn+JHnJRpmW90Z2EW50Ykmgcx2SZ++bm1rJEWlsKvxXiMdkQ7p0q bgqg== 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=WItcHhnO73E9uaui4Zhp0NFnluYWyeuLuk0/tMfNLB0=; b=uphNoE6i/B5Tfk3CJxep1Dih9LH/0dBTQ0Vj1Ze0qjnGS4Sd+J89Ry4WboxASuq25G 1Y+rjDu6H0j6qaXmurETNW8ZLBn228IXYE99ffRPgjxtHdaKwqS66XbYbLtYbc7X+1Li bLFf2qTX32zZk9d9A9zSL0waaZNLJo4ID3OzMavWmzc5eE8B9W7QKuH1LGLvruh+n0I/ q3ZFtMhVSrwubP78Aj07HjjnrYru11mqNQK6avMTWI/rlvrbcwhV6SEtMgUbO3itlF4+ DIoR8iF8JKqWPZ3B1Mz6YCLTcL+Qgqn19G4PpudrEPDmZgPpa/HBejaMsi0OqZ8Sl+CQ dkfA== 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 n3-v6si3197962pld.85.2018.04.10.11.18.10; Tue, 10 Apr 2018 11:18:48 -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 S1751836AbeDJSOx (ORCPT + 99 others); Tue, 10 Apr 2018 14:14:53 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:41328 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751490AbeDJSOv (ORCPT ); Tue, 10 Apr 2018 14:14:51 -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 BF1351435; Tue, 10 Apr 2018 11:14:50 -0700 (PDT) Received: from e108498-lin.cambridge.arm.com (e108498-lin.cambridge.arm.com [10.1.210.38]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CDFB73F592; Tue, 10 Apr 2018 11:14:47 -0700 (PDT) Date: Tue, 10 Apr 2018 19:14:42 +0100 From: Quentin Perret To: Peter Zijlstra Cc: Dietmar Eggemann , linux-kernel@vger.kernel.org, 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 5/6] sched/fair: Select an energy-efficient CPU on task wake-up Message-ID: <20180410181442.GA9565@e108498-lin.cambridge.arm.com> References: <20180406153607.17815-1-dietmar.eggemann@arm.com> <20180406153607.17815-6-dietmar.eggemann@arm.com> <20180410172932.GD4043@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180410172932.GD4043@hirez.programming.kicks-ass.net> 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 Tuesday 10 Apr 2018 at 19:29:32 (+0200), Peter Zijlstra wrote: > On Fri, Apr 06, 2018 at 04:36:06PM +0100, Dietmar Eggemann wrote: > > + for_each_freq_domain(fd) { > > + unsigned long spare_cap, max_spare_cap = 0; > > + int max_spare_cap_cpu = -1; > > + unsigned long util; > > + > > + /* Find the CPU with the max spare cap in the freq. dom. */ > > + for_each_cpu_and(cpu, freq_domain_span(fd), sched_domain_span(sd)) { > > + if (!cpumask_test_cpu(cpu, &p->cpus_allowed)) > > + continue; > > + > > + if (cpu == prev_cpu) > > + continue; > > + > > + util = cpu_util_wake(cpu, p); > > + cpu_cap = capacity_of(cpu); > > + if (!util_fits_capacity(util + task_util, cpu_cap)) > > + continue; > > + > > + spare_cap = cpu_cap - util; > > + if (spare_cap > max_spare_cap) { > > + max_spare_cap = spare_cap; > > + max_spare_cap_cpu = cpu; > > + } > > + } > > + > > + /* Evaluate the energy impact of using this CPU. */ > > + if (max_spare_cap_cpu >= 0) { > > + cur_energy = compute_energy(p, max_spare_cap_cpu); > > + if (cur_energy < best_energy) { > > + best_energy = cur_energy; > > + best_energy_cpu = max_spare_cap_cpu; > > + } > > + } > > + } > > If each CPU has its own frequency domain, then the above loop ends up > being O(n^2), no? Hmmm, yes, that should be O(n^2) indeed. > Is there really nothing we can do about that? So, the only thing I see just now would be to make compute_energy() smarter somehow. Today we compute the energy consumed by each frequency domain and then sum them up to get the system energy. We re-compute the energy of each frequency domain, even when it is not involved in the migration. In the case you describe, we will end up re-computing the energy of many frequency domains on which nothing happens every time we re-call compute_energy(). So there is probably something we could do by caching those values somehow. Otherwise, on systems with 2 frequency domains (e.g. big.LITTLE), the current code should behave relatively well. And I think that covers a large portion of the real-world systems for which EAS is useful, as of today at least ... :-) > Also, I > feel that warrants a comment warning about this. > > Someone, somewhere will try and build a 64+64 cpu system and get > surprised it doesn't work :-)