Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3332403ybc; Thu, 21 Nov 2019 06:52:56 -0800 (PST) X-Google-Smtp-Source: APXvYqx8pQV0oa5qrYe5QnLPLTZlUigcfup7gBMWMpwmNolQ74uOyLyPVsVeeCkD7ZNF+i7cs8Wx X-Received: by 2002:a17:906:1d41:: with SMTP id o1mr14675131ejh.333.1574347976365; Thu, 21 Nov 2019 06:52:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574347976; cv=none; d=google.com; s=arc-20160816; b=UGr0esulA3QsGb+p+4mDg6Lz6P9P8pZKSYTQEZ56gmqVmwE8Ozq9ONpWXheCWiSZ/Q 3nIUgXS/r2zdT377ozxND6jcTzTsUgsAtC/4P6kf2vU1B/IXZKHMMeoDD8K2PaRyI+6m PZhT6wm2pGU2OLffZZMLP20VOzmwoeAMiUt0jyt+8L+sXGNchFOn6HWCJFJIr4g05tuZ MJ6T2vmmYett1xIVAJmNtObyD9R/85BNQ1I8lKePPJnqqs1uwcoEgB2PudzPwWELrCIA xlye19kV61SyqAYV1Wo+Zf4WSpfl+IjtHhHfH8/BwOzHadb4OYilBYHymMwHvJMF3B+E hU2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=O3lXv0Sv/MRW6goqJiqGGo2KKOXKAjMUOHAHW4X3G/Y=; b=b0lbcVcRIpsUYFc/u74p0imjKI+lmURwZ4jIapSKdDy7FZs/LN24xw/5L+DcZiv8ed 1hDSRcGWY2fKbse+JQ7KwX1GxaRSAsWzK/yCIWGzfdAVi0GTxNpjrre4W4t5KQ04I5Nt 1R4osAKHzv3p3PmloIxtfvdgL0QZt3nrx5snnYFGZ3ToFitYZVEIKxjILs6KzjerUexU 0V6GArKiOvXXO+8v7VmeahB+auR0KXjKaCxheHXMR15lDRRPjCqRGeL9AzeIQP73NxOt R8ZK+iSpFl9GqD7hVS0aZbr7FBnEAtIoUj4xTTAf/V29suSEX2zF+i1dCjPHsxL+Wucd QtYg== 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 m15si1808132ejk.320.2019.11.21.06.52.32; Thu, 21 Nov 2019 06:52:56 -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; 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 S1726676AbfKUOvL (ORCPT + 99 others); Thu, 21 Nov 2019 09:51:11 -0500 Received: from foss.arm.com ([217.140.110.172]:57558 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726396AbfKUOvL (ORCPT ); Thu, 21 Nov 2019 09:51:11 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 161AFDA7; Thu, 21 Nov 2019 06:51:10 -0800 (PST) Received: from [10.0.2.15] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C4FB83F703; Thu, 21 Nov 2019 06:51:08 -0800 (PST) Subject: Re: [PATCH 3/3] sched/fair: Consider uclamp for "task fits capacity" checks To: Quentin Perret 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 References: <20191120175533.4672-1-valentin.schneider@arm.com> <20191120175533.4672-4-valentin.schneider@arm.com> <20191121115602.GA213296@google.com> <20191121133043.GA46904@google.com> From: Valentin Schneider Message-ID: <09e234a2-ea65-4d09-5215-9b0fe4ec09fe@arm.com> Date: Thu, 21 Nov 2019 14:51:06 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20191121133043.GA46904@google.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21/11/2019 13:30, Quentin Perret wrote: > 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. > Hm right, had to let that spin in my head for a while but I think I got it. I was only really thinking of: (h960: LITTLE = 462 cap, big = 1024) p.uclamp.min = 512 -> skip LITTLEs regardless of the actual util_est but your point is we also want stuff like: p.uclamp.max = 300 -> accept LITTLEs regardless of the actual util_est I'll keep the feec() change as-is and add something like the above in the changelog for v2. > 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 ? > uclamp_util_with() (or uclamp_rq_util_with() ;)) picks the max between the rq-aggregated clamps and the task clamps, which isn't what we want. If the task has a low-ish uclamp.max (e.g. the 300 example from above) but the rq-wide max-aggregated uclamp.max is ~800, we'd clamp using that 800. It makes sense for frequency selection, but not for task placement IMO. > Thanks, > Quentin >