Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp169635pxb; Mon, 25 Oct 2021 06:06:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxN0R7FVmIHrV6wEEYcCDYZv32/66JdG4Ak/k2/i/NkGS30Ju5og5Qv4xEjIRbXBh4NfYgO X-Received: by 2002:a63:330e:: with SMTP id z14mr13796005pgz.188.1635167216216; Mon, 25 Oct 2021 06:06:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635167216; cv=none; d=google.com; s=arc-20160816; b=0BlKEnMNk2rZYj0cVO1HJItlSDEe5ZCrcDxlQ6s2SoW560P+UEAHmoAz4v2BddCVWu rMRFtTzEEmUIxGbtkvf1kQm5pr2qQ/s1UAhLP8dVgczJOkwte44FIORK16zLQiciL3W7 ESGzzhPPNE4TeZV3yITlobzC7l716Gk0cWqNnxXN7KAzTEQeTSOiT+HbKjk9DvUfKFJP KaMn4251R4rnhl/vrjRrpI3+2qScQJcuo+kteJSWW5WAFz/N7H8NnAnLVp0rmyA3Bp1Y SGsBj5aUn94gpmIztgF9bE5/N6Rig4MvXafpMQ8Xtu8iyIhwDA4GOmS+ANSvYtjONF0r fgrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=bR722RD8MGeg2EVALvXkBsw1+yjigOC/aBt6DgZJiKk=; b=tbLJ2jo2txWhLo8w5ZFkycWeK/xt/2zwEt+2dZxYViInzTvDDeIyvPPeJu493hTbsa xG6JBH+/oTuzSVigO/HygBIgj3KRwdOps4eFLaQt4edbgcID9gw35MRPjkTaVcKowE2v Mm+o3kn9jcK5yMWS4b4gvEaEjn5TPvQTh2i7dalPSi8tvbxgJc6EYbQ+18Uy38uBp9AF jDvCf6ng3FI4ZZfxm5nze9xK2ITNu4jWDSNp9Qe7wgTL8gOZzpN0EDgFEz1LUe2OU/qF zi5qpCwy/THZI4+NWJO0sbRbDRUPn50mdkVF6IDss2NSekAhDJ2vNpaDZFoZ0twCCjwh PBOg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p5si29340218pgh.375.2021.10.25.06.06.41; Mon, 25 Oct 2021 06:06:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233254AbhJYNGt (ORCPT + 99 others); Mon, 25 Oct 2021 09:06:49 -0400 Received: from foss.arm.com ([217.140.110.172]:45472 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232168AbhJYNGs (ORCPT ); Mon, 25 Oct 2021 09:06:48 -0400 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 2CEA6D6E; Mon, 25 Oct 2021 06:04:26 -0700 (PDT) Received: from [172.29.15.235] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EA67B3F5A1; Mon, 25 Oct 2021 06:04:23 -0700 (PDT) Subject: Re: [RFC PATCH] sched/fair: use max_spare_cap_cpu if it is more energy efficient To: Xuewen Yan , brookxu Cc: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Steven Rostedt , Benjamin Segall , Mel Gorman , Daniel Bristot de Oliveira , linux-kernel References: <1634804594-4163-1-git-send-email-brookxu.cn@gmail.com> From: Dietmar Eggemann Message-ID: Date: Mon, 25 Oct 2021 15:04:47 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 22/10/2021 06:05, Xuewen Yan wrote: > Hi Chunguang > > brookxu 于2021年10月21日周四 下午4:24写道: >> >> From: Chunguang Xu >> >> When debugging EAS, I found that if the task is migrated to >> max_spare_cap_cpu, even if the power consumption of pd is lower, The task p hasn't been migrated yet. `max_spare_cap_cpu` here is only a potential candidate CPU to be selected for p. >> we still put the task on prev_cpu. Maybe we should fix it. >> >> Signed-off-by: Chunguang Xu >> --- >> kernel/sched/fair.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c >> index ff69f245b939..2ae7e03de6d2 100644 >> --- a/kernel/sched/fair.c >> +++ b/kernel/sched/fair.c >> @@ -6867,8 +6867,10 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu) >> /* Evaluate the energy impact of using max_spare_cap_cpu. */ >> if (max_spare_cap_cpu >= 0) { >> cur_delta = compute_energy(p, max_spare_cap_cpu, pd); >> - if (cur_delta < base_energy_pd) > > this is aimed to prevent the cur_delta < 0, and usuallly, when the > task was put on the max_spare_cpu, the cur_power should be bigger than > base_pd_power, > if the cur_power < base_pd_power, the cpu util may have changed, at > this time, we should keep prev_cpu. > > You can look at below discuss and patch: > https://lore.kernel.org/all/20210429101948.31224-3-Pierre.Gondois@arm.com/ > https://lore.kernel.org/all/CAB8ipk_vgtg5d1obH36BYfNLZosbwr2k_U3xnAD4=H5uZt_M_g@mail.gmail.com/ That's correct. `prev_delta < base_energy_pd` or `cur_delta < base_energy_pd` indicate the rare case that `compute_energy() { -> cpu_util_next() -> cpu util }` returns a higher energy value for the perf domain w/o the task p than w/ it. `base_energy_pd` stands for the energy spend on the CPUs of the Perf Domain (PD) w/o considering the task p (compute_energy(p, *-1*, pd)), `dst_cpu == -1`. If this happens to a candidate CPU (prev_cpu or a per-PD max_spare_cap_cpu) we bail out and return target (i.e. prev_cpu) because we can't compare the energy values (prev_delta and best_delta) later on in this case. [...]