Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3239170ybc; Thu, 21 Nov 2019 05:33:06 -0800 (PST) X-Google-Smtp-Source: APXvYqzp/JRqPv/NAiarr5O1cIY3nLZs7UsAP9P7P5jKV9egaO1Nwr70F555fUjrZ9OL3VpQ4Kri X-Received: by 2002:adf:e3c6:: with SMTP id k6mr10408863wrm.135.1574343186251; Thu, 21 Nov 2019 05:33:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574343186; cv=none; d=google.com; s=arc-20160816; b=ZD/N7KLuxmHPQ19r1CQNfZk6hhmDzUIxa+Vku/n4k665ykKoPog9Jnd9pcfBr2kjgm Ihyp3pOX4t9eYnPg8CoXvfEwnzTVMkPFTFg6LE0/a6dj3pfQ1cOQR6Qh1NnARvAFwsRQ jhRE+lrPJT5HYrZWdd5EIhZ6iYb4PtDpPnXO4QenKC8cc89mqDk1s4UEFEkJ3LzMIwuL ixoyEqinVGyO6fA5ISVXbx4fS4GbhOwE40GpYwYOIbi/NLbQDPQOIjjfUd44rMoRXcd6 1c1e8YUFJJbDa+ORA0me2I29rl5FpNM7ijZBCl0SU4ycDk/c2wHjbGniYR0j8Pe0JZjO vClA== 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; bh=Jo+ES8Xc5JRhOigJYOHMRS0C9xfeoUlcZgoW8bE/klw=; b=Ab5Rcu9cpZfs4uNUIS1K4bSAMlus31eMrY+LI/QznTCmaIuhKgk9/OM/UETQLNwRKB R7Mz55YQ0VQkil5ivdHV244uKk6mlYI5/9nhLQsSyyqKNf60300HXeCCjdJxbH17QmS4 e/OWo1c8G+Z7JSc00DKoYVBVNplGIxbS08ML7/Z0gUo+dk/CuisEkdYJnJAOdmbfIyEd 9uxNpLSmvhC8uoG0Bjwc/BYB9iQ+SrEAPOJ7sjt4ZeK+Q+VFHnCxfHf+kgDSJJLbNZJH tIOikhoeGXU0RjJBehfyv9dWC6y56Ee0Q+NLMTgtEOCWBebUD0rlHGMyg0c9F7FiIcho Pahg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=WOqsXLW2; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l24si2014317edw.352.2019.11.21.05.32.42; Thu, 21 Nov 2019 05:33:06 -0800 (PST) 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=pass header.i=@google.com header.s=20161025 header.b=WOqsXLW2; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726655AbfKUNau (ORCPT + 99 others); Thu, 21 Nov 2019 08:30:50 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:51829 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726358AbfKUNau (ORCPT ); Thu, 21 Nov 2019 08:30:50 -0500 Received: by mail-wm1-f66.google.com with SMTP id g206so3457956wme.1 for ; Thu, 21 Nov 2019 05:30:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Jo+ES8Xc5JRhOigJYOHMRS0C9xfeoUlcZgoW8bE/klw=; b=WOqsXLW22kr4axDfqEH5dPhsTbkK5xKkbZfYrn+lbxNAo3grp4lJI62h4bBNN6zfqN h0Ezl+mfeIlN4g/wUslgGqCDuY4OzJsQk4qA41onqSgrwJv1c15So7vTaANZiV7xTFel UkFldHazH0+pYJwf9XZpxPpBvII5ZuZUGU08ovJIOY5spfr0DlUwgXDx1buJbVU+D8XZ nAgL359OjUCojdYI+zxZZEUy3ponYMJZxpDPBvppuVzB4aLgpG6voOHT1+z813EeQdES G4QPrletLL3WzD/ncqxZrlNM69ATLY/tEacFoJIIBxuMon8uJRU3U6rz+ftoioaDOCVg wHiw== 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=Jo+ES8Xc5JRhOigJYOHMRS0C9xfeoUlcZgoW8bE/klw=; b=SN0CP/y6IXHnEz964gMLc81X+ps+FP+xmnQitXAZbxRX8ubdDb4tyeTl6m8Y+RN3CG eyYyyQUEXt+vQXCzyYZCx7KFvIankEmCkBH4iUaNTxcCAk0H2zhpV3UaxPfsNHKnhufN CtgI0DJDKk8jH/kE8pIPUsaCBIr/KoEQY5NQKqSESwF4GO0hPrfmm7E6myf/zztPRVxV hmmLgNHkoqgCjfZEg7Inb3pRNq4gOrLpba4me/yqsU7zo4Myj1WZdk6HrWcP/2gUzoCw PVMCZM0kM3i8WKreM5DxOH/hJVatLFOA1k7nBVjeR8fiQrnWgte4Kbq7YtUo1I6be591 /hyw== X-Gm-Message-State: APjAAAW9le/G7iZ0+aVGUI/C13zSyQc3DUiIuAE3wa82LjOhuatCrff6 /usqhRzK6Uqenc47b65kCJNWDw== X-Received: by 2002:a7b:c747:: with SMTP id w7mr10380769wmk.62.1574343047861; Thu, 21 Nov 2019 05:30:47 -0800 (PST) Received: from google.com ([2a00:79e0:d:110:d6cc:2030:37c1:9964]) by smtp.gmail.com with ESMTPSA id f67sm2994421wme.16.2019.11.21.05.30.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2019 05:30:47 -0800 (PST) Date: Thu, 21 Nov 2019 13:30:43 +0000 From: Quentin Perret To: Valentin Schneider Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@kernel.org, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, patrick.bellasi@matbug.net, qais.yousef@arm.com, morten.rasmussen@arm.com Subject: Re: [PATCH 3/3] sched/fair: Consider uclamp for "task fits capacity" checks Message-ID: <20191121133043.GA46904@google.com> References: <20191120175533.4672-1-valentin.schneider@arm.com> <20191120175533.4672-4-valentin.schneider@arm.com> <20191121115602.GA213296@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thursday 21 Nov 2019 at 12:56:39 (+0000), Valentin Schneider wrote: > > @@ -6274,6 +6274,15 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu) > > if (!fits_capacity(util, cpu_cap)) > > continue; > > > > + /* > > + * Skip CPUs that don't satisfy uclamp requests. Note > > + * that the above already ensures the CPU has enough > > + * spare capacity for the task; this is only really for > > + * uclamp restrictions. > > + */ > > + if (!task_fits_capacity(p, capacity_orig_of(cpu))) > > + continue; > > This is partly redundant with the above, I think. What we really want here > is just > > fits_capacity(uclamp_eff_value(p, UCLAMP_MIN), capacity_orig_of(cpu)) > > but this would require some inline #ifdeffery. This suggested change lacks the UCLAMP_MAX part, which is a shame because this is precisely in the EAS path that we should try and down-migrate tasks if they have an appropriate max_clamp. So, your first proposal made sense, IMO. Another option to avoid the redundancy would be to do something along the lines of the totally untested diff below. diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 69a81a5709ff..38cb5fe7ba65 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6372,9 +6372,12 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu) if (!cpumask_test_cpu(cpu, p->cpus_ptr)) continue; - /* Skip CPUs that will be overutilized. */ util = cpu_util_next(cpu, p, cpu); cpu_cap = capacity_of(cpu); + spare_cap = cpu_cap - util; + util = uclamp_util_with(cpu_rq(cpu), util, p); + + /* Skip CPUs that will be overutilized. */ if (!fits_capacity(util, cpu_cap)) continue; @@ -6389,7 +6392,6 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu) * Find the CPU with the maximum spare capacity in * the performance domain */ - spare_cap = cpu_cap - util; if (spare_cap > max_spare_cap) { max_spare_cap = spare_cap; max_spare_cap_cpu = cpu; Thoughts ? Thanks, Quentin