[v2,2/3] sched/uclamp: Ignore (util == 0) optimization in feec() when p_util_max = 0
Message ID | 20230205224318.2035646-3-qyousef@layalina.io |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1960960wrn; Sun, 5 Feb 2023 15:19:14 -0800 (PST) X-Google-Smtp-Source: AK7set+7PBvyhiIoMjfI7ipPsKl6Cw1VlAuGeX6A20DjWpRJ0rlHdXb5RZE/YvMnFXDbSyVuQPRs X-Received: by 2002:a17:907:362:b0:839:74cf:7c4f with SMTP id rs2-20020a170907036200b0083974cf7c4fmr18344031ejb.8.1675639154775; Sun, 05 Feb 2023 15:19:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675639154; cv=none; d=google.com; s=arc-20160816; b=VXSDQpn1f9UVCUYJDUevNNEn27MSkzenl59jKlc96qQ3a/yFfMti/HagBoGFGfHk7c qUxR1shrFZrNnBUIWXL8OFkJeq/A9PsspsF6IIUUY6v/NSfu8FqV8IcZiXOigVTiBBSg 6AIAdA2zFfL7/w9KnPOukkiHeLaKFesl1qRsdQ1pNN++Vd+vRKkj2rIQTKMjZCUWP4EQ x2UIYh3sIElzF7rxDZGpXC7C7T79FlBsYRStoezEgBIKmftMLKtMTQQLY5b3EBJ6REew lpD5eDeyRcbeYcW20+DRpKIF1ArUZK0WcSrYtC19DKUJ9S8EGSMGPF7bwjhKP+Ka+79n Gpfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iqPeO/kNGQGc1U6cNoUfj1cL/02jGGj55jKIfeMBJNg=; b=AtasHvE8Qou78fY86dU8Bq8tlKyZpzesRZZibaA/xADEN2GauXymFBEXQLzr6mvpT3 /Bt8S1mtSXVU8SD1PoGJZ5DHZryYOpb+wNelmFCFVZz6PcDb+aSbf9nsj6lB6Owg4/p0 ut1w5wADcXpStMylMZjSFDGid+Am/xAKr7y5ahCkRAfvI5Utj01prhbW+cqcYR6sa86e DVr7dSOjwaZg+X164Kypr2ka5d7WRkvqYKxm/KKUaxezq1nZr+SQRtsAKE8cw+oe/Zcy 3euLDhUtHQi0n8eEdejayj8n6UGydPdydczWooo58Z2pmzZvgF5SV9tlC8ZgbhC+Fb4Y R4/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@layalina-io.20210112.gappssmtp.com header.s=20210112 header.b=apA3c6eD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wc6-20020a170907124600b008327270a7e0si9744281ejb.65.2023.02.05.15.18.49; Sun, 05 Feb 2023 15:19:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@layalina-io.20210112.gappssmtp.com header.s=20210112 header.b=apA3c6eD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229651AbjBEWni (ORCPT <rfc822;kmanaouilinux@gmail.com> + 99 others); Sun, 5 Feb 2023 17:43:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229621AbjBEWng (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 5 Feb 2023 17:43:36 -0500 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50DDF1A97A for <linux-kernel@vger.kernel.org>; Sun, 5 Feb 2023 14:43:35 -0800 (PST) Received: by mail-ej1-x633.google.com with SMTP id ud5so29496468ejc.4 for <linux-kernel@vger.kernel.org>; Sun, 05 Feb 2023 14:43:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iqPeO/kNGQGc1U6cNoUfj1cL/02jGGj55jKIfeMBJNg=; b=apA3c6eDRcMeQ3Nve4KdAFI74pKWD9vJPKKZpCZ/HAILY0DgzjeQcRi8Zb9Zkf8TqJ 4Rn8f9MDiKOJ0oeNkWy/rmJtbw7/VfoxMWzPnKw1PRj0r3v+ubz8dwRO/76dBhWn28cn WWELacMc7LuFipok14FAxsmsSLq0A2UrB4jgEetCe6fEITMmMtAeK9o2pyPjaTVt2QIh oDyRaNdUKF+AlM5v/lcZLFfd78jjKoFuFNT5P6Di66OQdl3Y1tG7swhrK/i3Kqrs8Urv rJR53AfbAQ2M4lH8HRSnBd21qh+viMQWXsIhp/3iTHPBzlV8QC0Eq+GELeuhGcGm4/a1 9R5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iqPeO/kNGQGc1U6cNoUfj1cL/02jGGj55jKIfeMBJNg=; b=BDQ1VUAw+hJfE37QpViYQVd6egoE/4pVM4BAOkWslmzJunkp38fFXLdIuolPKfSWft P9rbQzmqMzkS53kmDVRChfBTNjD+fvIcfkAISjZIAZT8eE2BbZlx1TVUxgaEGjlALC9g MaWm56gCQHnIVgYviVHoqy/SX1uLUObg8+3yXIcs8I7/CAwEF0INYQy+6OxK7MxDTCLQ WpyLef73BkjIKXfBx8thE3FlfVfOObvbgGark64h4sM7nrXPc0LHyMHkorh2h3Lr1AGw 7EYRQS0sT73N1CZlWKu6Mej2qnrnzOxHncyGDv7PEAbZkt6/fcVPzBox37ekar2Y6pBP oqpQ== X-Gm-Message-State: AO0yUKWX5aYV736TxPjD8+wBAZSsVMSUPFhKY5xmnXLF+GZ5i0BmDS+S +bcOzgB8JlWxPRKygeUWh/fCReKm/fpd1Ktz X-Received: by 2002:a17:906:1291:b0:88a:73b7:6d5f with SMTP id k17-20020a170906129100b0088a73b76d5fmr14446059ejb.10.1675637013831; Sun, 05 Feb 2023 14:43:33 -0800 (PST) Received: from localhost.localdomain (host86-163-35-10.range86-163.btcentralplus.com. [86.163.35.10]) by smtp.gmail.com with ESMTPSA id m15-20020a1709061ecf00b0087bd2924e74sm4550779ejj.205.2023.02.05.14.43.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Feb 2023 14:43:33 -0800 (PST) From: Qais Yousef <qyousef@layalina.io> To: Ingo Molnar <mingo@kernel.org>, Peter Zijlstra <peterz@infradead.org>, Vincent Guittot <vincent.guittot@linaro.org>, Dietmar Eggemann <dietmar.eggemann@arm.com> Cc: linux-kernel@vger.kernel.org, Lukasz Luba <lukasz.luba@arm.com>, Wei Wang <wvw@google.com>, Xuewen Yan <xuewen.yan94@gmail.com>, Hank <han.lin@mediatek.com>, Jonathan JMChen <Jonathan.JMChen@mediatek.com>, Qais Yousef <qyousef@layalina.io> Subject: [PATCH v2 2/3] sched/uclamp: Ignore (util == 0) optimization in feec() when p_util_max = 0 Date: Sun, 5 Feb 2023 22:43:17 +0000 Message-Id: <20230205224318.2035646-3-qyousef@layalina.io> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230205224318.2035646-1-qyousef@layalina.io> References: <20230205224318.2035646-1-qyousef@layalina.io> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757035002440324949?= X-GMAIL-MSGID: =?utf-8?q?1757035002440324949?= |
Series |
Fix a couple of corner cases in feec() when using uclamp_max
|
|
Commit Message
Qais Yousef
Feb. 5, 2023, 10:43 p.m. UTC
find_energy_efficient_cpu() bails out early if effective util of the
task is 0. When uclamp is being used, this could lead to wrong decisions
when uclamp_max is set to 0. Cater for that.
Fixes: d81304bc6193 ("sched/uclamp: Cater for uclamp in find_energy_efficient_cpu()'s early exit condition")
Signed-off-by: Qais Yousef <qyousef@layalina.io>
---
kernel/sched/fair.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Sun, 5 Feb 2023 at 23:43, Qais Yousef <qyousef@layalina.io> wrote: > > find_energy_efficient_cpu() bails out early if effective util of the > task is 0. When uclamp is being used, this could lead to wrong decisions > when uclamp_max is set to 0. Cater for that. > > Fixes: d81304bc6193 ("sched/uclamp: Cater for uclamp in find_energy_efficient_cpu()'s early exit condition") > Signed-off-by: Qais Yousef <qyousef@layalina.io> > --- > kernel/sched/fair.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 7a21ee74139f..a8c3d92ff3f6 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -7374,7 +7374,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu) > target = prev_cpu; > > sync_entity_load_avg(&p->se); > - if (!uclamp_task_util(p, p_util_min, p_util_max)) > + if (!uclamp_task_util(p, p_util_min, p_util_max) && p_util_max != 0) The below should do the same without testing twice p_util_max: uclamp_task_util(p, p_util_min, ULONG_MAX) > goto unlock; > > eenv_task_busy_time(&eenv, p, prev_cpu); > -- > 2.25.1 >
On 07/02/2023 11:04, Vincent Guittot wrote: > On Sun, 5 Feb 2023 at 23:43, Qais Yousef <qyousef@layalina.io> wrote: >> >> find_energy_efficient_cpu() bails out early if effective util of the >> task is 0. When uclamp is being used, this could lead to wrong decisions >> when uclamp_max is set to 0. Cater for that. IMHO this needs a little bit more explanation. Someone could argue that 'util > 0, uclamp_min=0, uclamp_max=0' is a valid setup for a task which should let it appear as a task with 0 util (capped to 0). >> Fixes: d81304bc6193 ("sched/uclamp: Cater for uclamp in find_energy_efficient_cpu()'s early exit condition") >> Signed-off-by: Qais Yousef <qyousef@layalina.io> >> --- >> kernel/sched/fair.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c >> index 7a21ee74139f..a8c3d92ff3f6 100644 >> --- a/kernel/sched/fair.c >> +++ b/kernel/sched/fair.c >> @@ -7374,7 +7374,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu) >> target = prev_cpu; >> >> sync_entity_load_avg(&p->se); >> - if (!uclamp_task_util(p, p_util_min, p_util_max)) >> + if (!uclamp_task_util(p, p_util_min, p_util_max) && p_util_max != 0) > > The below should do the same without testing twice p_util_max: > uclamp_task_util(p, p_util_min, ULONG_MAX) Since uclamp_task_util() is only used here and we don't want to test for capping to 0 anymore, why not just get rid of this function and use: !(task_util_est(p) || p_util_min) [...]
On 02/08/23 12:52, Dietmar Eggemann wrote: > On 07/02/2023 11:04, Vincent Guittot wrote: > > On Sun, 5 Feb 2023 at 23:43, Qais Yousef <qyousef@layalina.io> wrote: > >> > >> find_energy_efficient_cpu() bails out early if effective util of the > >> task is 0. When uclamp is being used, this could lead to wrong decisions > >> when uclamp_max is set to 0. Cater for that. > > IMHO this needs a little bit more explanation. Someone could argue that > 'util > 0, uclamp_min=0, uclamp_max=0' is a valid setup for a task which > should let it appear as a task with 0 util (capped to 0). You want me to explain the purpose of the optimization then? The optimization skips energy calculation when util is 0 because the delta will be 0. But when uclamp_max = 0 util is not really 0 - consequently the delta will not be 0. Would such an explanation clarify things better? > > >> Fixes: d81304bc6193 ("sched/uclamp: Cater for uclamp in find_energy_efficient_cpu()'s early exit condition") > >> Signed-off-by: Qais Yousef <qyousef@layalina.io> > >> --- > >> kernel/sched/fair.c | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > >> index 7a21ee74139f..a8c3d92ff3f6 100644 > >> --- a/kernel/sched/fair.c > >> +++ b/kernel/sched/fair.c > >> @@ -7374,7 +7374,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu) > >> target = prev_cpu; > >> > >> sync_entity_load_avg(&p->se); > >> - if (!uclamp_task_util(p, p_util_min, p_util_max)) > >> + if (!uclamp_task_util(p, p_util_min, p_util_max) && p_util_max != 0) > > > > The below should do the same without testing twice p_util_max: > > uclamp_task_util(p, p_util_min, ULONG_MAX) > > Since uclamp_task_util() is only used here and we don't want to test for > capping to 0 anymore, why not just get rid of this function and use: > > !(task_util_est(p) || p_util_min) That would be better, yes! Question for you and Vincent. Do we really want this optimization? I started with removing it - then erred on the conservative side and kept it. I don't know how often we hit this case and I didn't see any benchmark run to be able to verify anything when I looked at the history. It seems helpful in theory - but why we save something if we ignore 0 but not 1 which I suspect will not produce a significant delta either. I don't mind keeping it - but I think worth thinking if it is really adding much. Cheers -- Qais Yousef
On 11/02/2023 19:01, Qais Yousef wrote: > On 02/08/23 12:52, Dietmar Eggemann wrote: >> On 07/02/2023 11:04, Vincent Guittot wrote: >>> On Sun, 5 Feb 2023 at 23:43, Qais Yousef <qyousef@layalina.io> wrote: >>>> >>>> find_energy_efficient_cpu() bails out early if effective util of the >>>> task is 0. When uclamp is being used, this could lead to wrong decisions >>>> when uclamp_max is set to 0. Cater for that. >> >> IMHO this needs a little bit more explanation. Someone could argue that >> 'util > 0, uclamp_min=0, uclamp_max=0' is a valid setup for a task which >> should let it appear as a task with 0 util (capped to 0). > > You want me to explain the purpose of the optimization then? > > The optimization skips energy calculation when util is 0 because the delta will > be 0. But when uclamp_max = 0 util is not really 0 - consequently the delta I would say: s/really/necessarily s/delta/energy delta > will not be 0. > > Would such an explanation clarify things better? Yes. It key to understand that there is a 2-step process. First, admittance to a possible target (util and uclamp) and second, energy diff based target-selection (util). >>>> Fixes: d81304bc6193 ("sched/uclamp: Cater for uclamp in find_energy_efficient_cpu()'s early exit condition") >>>> Signed-off-by: Qais Yousef <qyousef@layalina.io> >>>> --- >>>> kernel/sched/fair.c | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c >>>> index 7a21ee74139f..a8c3d92ff3f6 100644 >>>> --- a/kernel/sched/fair.c >>>> +++ b/kernel/sched/fair.c >>>> @@ -7374,7 +7374,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu) >>>> target = prev_cpu; >>>> >>>> sync_entity_load_avg(&p->se); >>>> - if (!uclamp_task_util(p, p_util_min, p_util_max)) >>>> + if (!uclamp_task_util(p, p_util_min, p_util_max) && p_util_max != 0) >>> >>> The below should do the same without testing twice p_util_max: >>> uclamp_task_util(p, p_util_min, ULONG_MAX) >> >> Since uclamp_task_util() is only used here and we don't want to test for >> capping to 0 anymore, why not just get rid of this function and use: >> >> !(task_util_est(p) || p_util_min) > > That would be better, yes! > > Question for you and Vincent. Do we really want this optimization? I started > with removing it - then erred on the conservative side and kept it. Hard to say ... at least we know that util=0 will have absolutely no effect on task placement. So we can spare the heavy EAS algorithm in this case for sure. > I don't know how often we hit this case and I didn't see any benchmark run to > be able to verify anything when I looked at the history. There are very few EAS wakeups with `task_util_est(p) = 0`. Probably not relevant. > It seems helpful in theory - but why we save something if we ignore 0 but not > 1 which I suspect will not produce a significant delta either. True, it's hard to find the real line of significance here. > I don't mind keeping it - but I think worth thinking if it is really adding > much. I would keep it and just remove uclamp_task_util(). We still have a lot of uclamp/util related functions, we should try to keep the number as low as possible. Just checked it, this check has been there from the beginning of EAS.
On 02/14/23 13:47, Dietmar Eggemann wrote: > On 11/02/2023 19:01, Qais Yousef wrote: > > On 02/08/23 12:52, Dietmar Eggemann wrote: > >> On 07/02/2023 11:04, Vincent Guittot wrote: > >>> On Sun, 5 Feb 2023 at 23:43, Qais Yousef <qyousef@layalina.io> wrote: > >>>> > >>>> find_energy_efficient_cpu() bails out early if effective util of the > >>>> task is 0. When uclamp is being used, this could lead to wrong decisions > >>>> when uclamp_max is set to 0. Cater for that. > >> > >> IMHO this needs a little bit more explanation. Someone could argue that > >> 'util > 0, uclamp_min=0, uclamp_max=0' is a valid setup for a task which > >> should let it appear as a task with 0 util (capped to 0). > > > > You want me to explain the purpose of the optimization then? > > > > The optimization skips energy calculation when util is 0 because the delta will > > be 0. But when uclamp_max = 0 util is not really 0 - consequently the delta > > I would say: > > s/really/necessarily > s/delta/energy delta +1 > > > will not be 0. > > > > Would such an explanation clarify things better? > > Yes. It key to understand that there is a 2-step process. First, > admittance to a possible target (util and uclamp) and second, energy > diff based target-selection (util). > > >>>> Fixes: d81304bc6193 ("sched/uclamp: Cater for uclamp in find_energy_efficient_cpu()'s early exit condition") > >>>> Signed-off-by: Qais Yousef <qyousef@layalina.io> > >>>> --- > >>>> kernel/sched/fair.c | 2 +- > >>>> 1 file changed, 1 insertion(+), 1 deletion(-) > >>>> > >>>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > >>>> index 7a21ee74139f..a8c3d92ff3f6 100644 > >>>> --- a/kernel/sched/fair.c > >>>> +++ b/kernel/sched/fair.c > >>>> @@ -7374,7 +7374,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu) > >>>> target = prev_cpu; > >>>> > >>>> sync_entity_load_avg(&p->se); > >>>> - if (!uclamp_task_util(p, p_util_min, p_util_max)) > >>>> + if (!uclamp_task_util(p, p_util_min, p_util_max) && p_util_max != 0) > >>> > >>> The below should do the same without testing twice p_util_max: > >>> uclamp_task_util(p, p_util_min, ULONG_MAX) > >> > >> Since uclamp_task_util() is only used here and we don't want to test for > >> capping to 0 anymore, why not just get rid of this function and use: > >> > >> !(task_util_est(p) || p_util_min) > > > > That would be better, yes! > > > > Question for you and Vincent. Do we really want this optimization? I started > > with removing it - then erred on the conservative side and kept it. > > Hard to say ... at least we know that util=0 will have absolutely no > effect on task placement. So we can spare the heavy EAS algorithm in > this case for sure. > > > I don't know how often we hit this case and I didn't see any benchmark run to > > be able to verify anything when I looked at the history. > > There are very few EAS wakeups with `task_util_est(p) = 0`. Probably not > relevant. > > > It seems helpful in theory - but why we save something if we ignore 0 but not > > 1 which I suspect will not produce a significant delta either. > > True, it's hard to find the real line of significance here. > > > I don't mind keeping it - but I think worth thinking if it is really adding > > much. > > I would keep it and just remove uclamp_task_util(). We still have a lot > of uclamp/util related functions, we should try to keep the number as > low as possible. Just checked it, this check has been there from the > beginning of EAS. Yeah I looked at the history and it was always there. I'll update with the new check and update the commit message too. Thanks! -- Qais Yousef
On Tue, 14 Feb 2023 at 13:47, Dietmar Eggemann <dietmar.eggemann@arm.com> wrote: > > On 11/02/2023 19:01, Qais Yousef wrote: > > On 02/08/23 12:52, Dietmar Eggemann wrote: > >> On 07/02/2023 11:04, Vincent Guittot wrote: > >>> On Sun, 5 Feb 2023 at 23:43, Qais Yousef <qyousef@layalina.io> wrote: > >>>> > >>>> find_energy_efficient_cpu() bails out early if effective util of the > >>>> task is 0. When uclamp is being used, this could lead to wrong decisions > >>>> when uclamp_max is set to 0. Cater for that. > >> > >> IMHO this needs a little bit more explanation. Someone could argue that > >> 'util > 0, uclamp_min=0, uclamp_max=0' is a valid setup for a task which > >> should let it appear as a task with 0 util (capped to 0). > > > > You want me to explain the purpose of the optimization then? > > > > The optimization skips energy calculation when util is 0 because the delta will > > be 0. But when uclamp_max = 0 util is not really 0 - consequently the delta > > I would say: > > s/really/necessarily > s/delta/energy delta > > > will not be 0. > > > > Would such an explanation clarify things better? > > Yes. It key to understand that there is a 2-step process. First, > admittance to a possible target (util and uclamp) and second, energy > diff based target-selection (util). > > >>>> Fixes: d81304bc6193 ("sched/uclamp: Cater for uclamp in find_energy_efficient_cpu()'s early exit condition") > >>>> Signed-off-by: Qais Yousef <qyousef@layalina.io> > >>>> --- > >>>> kernel/sched/fair.c | 2 +- > >>>> 1 file changed, 1 insertion(+), 1 deletion(-) > >>>> > >>>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > >>>> index 7a21ee74139f..a8c3d92ff3f6 100644 > >>>> --- a/kernel/sched/fair.c > >>>> +++ b/kernel/sched/fair.c > >>>> @@ -7374,7 +7374,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu) > >>>> target = prev_cpu; > >>>> > >>>> sync_entity_load_avg(&p->se); > >>>> - if (!uclamp_task_util(p, p_util_min, p_util_max)) > >>>> + if (!uclamp_task_util(p, p_util_min, p_util_max) && p_util_max != 0) > >>> > >>> The below should do the same without testing twice p_util_max: > >>> uclamp_task_util(p, p_util_min, ULONG_MAX) > >> > >> Since uclamp_task_util() is only used here and we don't want to test for > >> capping to 0 anymore, why not just get rid of this function and use: > >> > >> !(task_util_est(p) || p_util_min) > > > > That would be better, yes! > > > > Question for you and Vincent. Do we really want this optimization? I started > > with removing it - then erred on the conservative side and kept it. > > Hard to say ... at least we know that util=0 will have absolutely no > effect on task placement. So we can spare the heavy EAS algorithm in > this case for sure. > > > I don't know how often we hit this case and I didn't see any benchmark run to > > be able to verify anything when I looked at the history. > > There are very few EAS wakeups with `task_util_est(p) = 0`. Probably not > relevant. > > > It seems helpful in theory - but why we save something if we ignore 0 but not > > 1 which I suspect will not produce a significant delta either. > > True, it's hard to find the real line of significance here. > > > I don't mind keeping it - but I think worth thinking if it is really adding > > much. > > I would keep it and just remove uclamp_task_util(). We still have a lot > of uclamp/util related functions, we should try to keep the number as > low as possible. Just checked it, this check has been there from the > beginning of EAS. Yes make sense to keep the test as proposed by Dietmar and save the cycles >
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 7a21ee74139f..a8c3d92ff3f6 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7374,7 +7374,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu) target = prev_cpu; sync_entity_load_avg(&p->se); - if (!uclamp_task_util(p, p_util_min, p_util_max)) + if (!uclamp_task_util(p, p_util_min, p_util_max) && p_util_max != 0) goto unlock; eenv_task_busy_time(&eenv, p, prev_cpu);