Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4908337imm; Tue, 19 Jun 2018 01:43:34 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLsfBwQjBqlCM/fUripPR52tC4+m9rlc7mPV/oIydr1ectXHcgj9ojthJVbhwh1FgViuCgR X-Received: by 2002:a62:4bc8:: with SMTP id d69-v6mr17259153pfj.244.1529397814235; Tue, 19 Jun 2018 01:43:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529397814; cv=none; d=google.com; s=arc-20160816; b=ep7fDvnPTQU3NrlzODKRyjYJAAhk1+odZQSCx+z+JJk1fQaEVlxWkNKrcwwlZxAU25 BALv5ChyedOwuIVLOGsa+sysW8tU+0ZGaMMeGy7cjb4FsclF9FS335/exY5d/2DmAqU4 pujMNbFulQLgOEJBsth6hRIDyuFGOooTlFUqCQ/825jkWuPBeNkBRku+tPX5+Eh+B5aI QVQCcrFvQtyBVd/6/GS1K4UXGGqbWcxamQ/g7BLiA4kug65ar0QNk54kY6crz5tJShvY LZwvSjqOwOaxv5QPfqcBpe8PnzsVXT7imLj0VFJlaLzOwOAHqusriQILGPxR5WKvuIAP U0gQ== 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:dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=umZCuo0lQNCIz34xvLtVmnJbmob5N+YjrEsNVCpR1U4=; b=sHvYGzW8i0VRKafb8cQuguCjwcXmmj+NJTwvI8CZLqiB5vaZYyiNKz/HHx7ON+BgNl 1KmZrPmxglGrg3zM35Jtb5fhUlNqwlLNE1/VPaiGk2/d7cpJJ3WivO+veVoh/dBv92Kb w+YFDEXMrvW8QtjnllPqalw/JhrGyy2fOKYejcaae2cDepLoo7ez7QuzmPB1mHzLaYGI XcFeaRxe6f2r9lIDrCtcF66BQRFzr0rRlgWLXN8VuA0o1qmwpUDuGS0RupdU9DX7S2Jp wm+/ydXw8rJDAk+F+Q4ks5hhhZ12oAd+fdNv+zui+N/yCODfo7PRK9T0SMWcalRGJe49 qjHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=G+OoRuIn; dkim=pass header.i=@codeaurora.org header.s=default header.b=l+mYHUmL; 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 i16-v6si16868989pfi.234.2018.06.19.01.43.20; Tue, 19 Jun 2018 01:43:34 -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=pass header.i=@codeaurora.org header.s=default header.b=G+OoRuIn; dkim=pass header.i=@codeaurora.org header.s=default header.b=l+mYHUmL; 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 S937418AbeFSImM (ORCPT + 99 others); Tue, 19 Jun 2018 04:42:12 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:57564 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S937388AbeFSImJ (ORCPT ); Tue, 19 Jun 2018 04:42:09 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 79EDF60B22; Tue, 19 Jun 2018 08:42:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1529397728; bh=4Ba4/fiIAe8okicJw+AvqtN/NuFAKYXniN1wWK3qRFE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=G+OoRuInx/KhZNRRiHRS48iIef41OoFaOrls0Osp/PpgMHr1ktExm+ydeKoM457i7 CzZUVadtcwNnXslwA1fraCGbk98lMgqB7cgHqwzDESnwnM+82YkxU6P/NcPyUJE5vZ m85Po0JbqP7bCyQhc4kBxt5jOvxrpYbE7W2sESpo= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from codeaurora.org (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: pkondeti@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 3214F60B7A; Tue, 19 Jun 2018 08:41:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1529397726; bh=4Ba4/fiIAe8okicJw+AvqtN/NuFAKYXniN1wWK3qRFE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=l+mYHUmLf4fteU6ZkKBnbLrfg9XMPVwK6MyNPyuyvVDRve+ZbQUiElLttAx+qAkEH VBJZUYoMoc0EtZErFU4b9cgrf/t1U3VVuVcnWwLu/Z45gySR9vQRU4Mb0AUxAFTSgE l/s0v7yIGmJqj5LtZNzWZe28aQm2dRlPPnZ4jMj8= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 3214F60B7A Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=pkondeti@codeaurora.org Date: Tue, 19 Jun 2018 14:11:56 +0530 From: Pavan Kondeti To: Quentin Perret Cc: peterz@infradead.org, rjw@rjwysocki.net, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, mingo@redhat.com, dietmar.eggemann@arm.com, morten.rasmussen@arm.com, chris.redpath@arm.com, patrick.bellasi@arm.com, valentin.schneider@arm.com, vincent.guittot@linaro.org, thara.gopinath@linaro.org, viresh.kumar@linaro.org, tkjos@google.com, joelaf@google.com, smuckle@google.com, adharmap@quicinc.com, skannan@quicinc.com, juri.lelli@redhat.com, edubezval@gmail.com, srinivas.pandruvada@linux.intel.com, currojerez@riseup.net, javi.merino@kernel.org Subject: Re: [RFC PATCH v3 09/10] sched/fair: Select an energy-efficient CPU on task wake-up Message-ID: <20180619084156.GC9208@codeaurora.org> References: <20180521142505.6522-1-quentin.perret@arm.com> <20180521142505.6522-10-quentin.perret@arm.com> <20180619050601.GA9208@codeaurora.org> <20180619075723.GQ17720@e108498-lin.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180619075723.GQ17720@e108498-lin.cambridge.arm.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 19, 2018 at 08:57:23AM +0100, Quentin Perret wrote: > Hi Pavan, > > On Tuesday 19 Jun 2018 at 10:36:01 (+0530), Pavan Kondeti wrote: > > On Mon, May 21, 2018 at 03:25:04PM +0100, Quentin Perret wrote: > > > > > > > > > + if (cpumask_test_cpu(prev_cpu, &p->cpus_allowed)) > > > + prev_energy = best_energy = compute_energy(p, prev_cpu); > > > + else > > > + prev_energy = best_energy = ULONG_MAX; > > > + > > > + for_each_freq_domain(sfd) { > > > + 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(sfd), sched_domain_span(sd)) { > > > + if (!cpumask_test_cpu(cpu, &p->cpus_allowed)) > > > + continue; > > > + > > > + if (cpu == prev_cpu) > > > + continue; > > > + > > > + /* Skip CPUs that will be overutilized */ > > > + util = cpu_util_wake(cpu, p) + task_util; > > > + cpu_cap = capacity_of(cpu); > > > + if (cpu_cap * 1024 < util * capacity_margin) > > > + 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; > > > + } > > > + } > > > + } > > > + > > > + /* > > > + * We pick the best CPU only if it saves at least 1.5% of the > > > + * energy used by prev_cpu. > > > + */ > > > + if ((prev_energy - best_energy) > (prev_energy >> 6)) > > > + return best_energy_cpu; > > > + > > > + return prev_cpu; > > > +} > > > > We are comparing the best_energy_cpu against prev_cpu even when prev_cpu > > can't accommodate the waking task. Is this intentional? Should not we > > discard the prev_cpu if it can't accommodate the task. > > > > This can potentially make a BIG task run on a lower capacity CPU until > > load balancer kicks in and corrects the situation. > > We shouldn't enter find_energy_efficient_cpu() in the first place if the > system is overutilized, so that shouldn't too much of an issue in > general. > With UTIL_EST enabled, the overutilization condtion may get turned off when that 1 BIG task goes to sleep. When it wakes up again, we may place it on the previous CPU due to the above mentioned issue. It is not just an existing overutilization condition. By placing this task on the prev_cpu, we may enter overutilization state. > But yeah, there is one small corner case where prev_cpu is overutilized > and the system has not been flagged as such yet (when the tasks wakes-up > shortly before the tick for ex). I think it's possible to cover this case > by extending the "if (cpumask_test_cpu(prev_cpu, &p->cpus_allowed))" > condition at the top of the function with a check on capacity_margin. > LGTM. -- Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.