Received: by 10.213.65.68 with SMTP id h4csp4185578imn; Tue, 10 Apr 2018 10:33:06 -0700 (PDT) X-Google-Smtp-Source: AIpwx49mBHJ9g2cVqy41PHgHXvwqKX8qT5tk1G2fouuNfgsKHZbu6dYWiQ+iW9od0eFlr46+k6C8 X-Received: by 10.98.211.4 with SMTP id q4mr1168909pfg.0.1523381586673; Tue, 10 Apr 2018 10:33:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523381586; cv=none; d=google.com; s=arc-20160816; b=GH9HJhU25fNpX2CTACxp6MyGxE5BeFQrY8lfyYiOPOuEaSi1aCFNUnDBSQSn+gtiCr ztl1GYgpksX6NW2Lw7JIrePv7WfW8L+y455RNQqiCU+pkpAjADzyX/YXjgwuo4mZJ8HU JLbIlZg/F5ROu8BvE+Kk6GdoDx620r4DvOny+2XXx8cKVX3YNLS1TVzE/UnW6UCv1WSq XG0xr504xCaDI5kas6lovswvXtfuoUaGusuF6mNAjld9p/lDHhC6bpr76M9ttvAwFKXU NyXJYtNpZO+uOdJi7naLJAQQGA9hBRMaAQg/AWk+uf9q83hCCAQG3h/34Al6B+ZAzE6K tI6g== 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:dkim-signature:arc-authentication-results; bh=X7d/vXVZF9r2BNWDVQZmiRak52aEtdt4B7MeoH53T7E=; b=oZwtDpiICpsHwjpfu5Yj1tYpE0FsydaJHEDQGHZggCAZ8Gih7MCKJErpSMdYK+ylex 8bc7gp0XWgf4HlDt3crnhbst+esc+zyTFFKod9rqYJqPL3eDs7lzAV8i+hIeoNHi19vC euSQZR2FO3326XeqA8j1QNScDkPPjIuTJCvJ3WmGhO3fTUtnroLemqOIq5eWew5q8rOD mTYXFfMj+poUJ+L8QyGpRR99MqnfAkS4Yaq+cutNpZMowY6D6rW9ynW0yGWo000gkYKE lmNMRFCwoXsFEqHvWWmfeOdSxtn2w9p8xXXM8jcpZPOGIHdlldvyRDpCJ5AuhTXOLBZ5 YOEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=HC3whXb8; 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 r16si2362185pfh.333.2018.04.10.10.32.29; Tue, 10 Apr 2018 10:33:06 -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; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=HC3whXb8; 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 S1751886AbeDJR3s (ORCPT + 99 others); Tue, 10 Apr 2018 13:29:48 -0400 Received: from merlin.infradead.org ([205.233.59.134]:36822 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751367AbeDJR3q (ORCPT ); Tue, 10 Apr 2018 13:29:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=X7d/vXVZF9r2BNWDVQZmiRak52aEtdt4B7MeoH53T7E=; b=HC3whXb8vLd3jsFvkG1lfl/Xk IDk2VREvAdkSJDoxk6kc5QM/gC/WmuXpStjRTnkoCbb1f+A0b4Zq8q/NhGyKSk/V362DAUYr0/gmK ghMq0Dbr8U+kEZ/7bBbpVUzpfpnzaPA3cpW8T1dp1edP8Sf2X1wzcekwyfsej0zQeIhWDAz2uCLEH Vj1188VB215P5FzCnkOm/9k6W9qbVykwqLQBj6Zap3yroFxOL8CyMgkfcH5y5mx1dUlfX+zbm4rkW PklFZYqkrxiYMKIDj3GXHO4ujWPZRqrskEuv+4yzrwVLFMllqYbCgpQLdiWBNoy4g3dNyt3xyE9cG BPNlFU7+g==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1f5x5J-0006Wn-SP; Tue, 10 Apr 2018 17:29:34 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 81EA02029B0F9; Tue, 10 Apr 2018 19:29:32 +0200 (CEST) Date: Tue, 10 Apr 2018 19:29:32 +0200 From: Peter Zijlstra To: Dietmar Eggemann Cc: linux-kernel@vger.kernel.org, Quentin Perret , 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: <20180410172932.GD4043@hirez.programming.kicks-ass.net> References: <20180406153607.17815-1-dietmar.eggemann@arm.com> <20180406153607.17815-6-dietmar.eggemann@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180406153607.17815-6-dietmar.eggemann@arm.com> User-Agent: Mutt/1.9.3 (2018-01-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? Is there really nothing we can do about that? 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 :-)