Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4421804ioa; Wed, 27 Apr 2022 03:36:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMllwU8MmB5XrvtoTGcc/AXAjUEje057ljCDJ58WRdJZ/mY4M4nZOfO4CZ0rbOtDSQj5L2 X-Received: by 2002:a63:8542:0:b0:3ab:4911:ec35 with SMTP id u63-20020a638542000000b003ab4911ec35mr12171310pgd.356.1651055783700; Wed, 27 Apr 2022 03:36:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651055783; cv=none; d=google.com; s=arc-20160816; b=OaDWLuGHVk/LLcstCiLYDP5z6KHfOzWdfp8jAUlPub5YkJJ3q05Zy6Efp0UdWn6Eki AXC3hgy5UZQ2lyAK5biFHFjlV5XaDzkaolrtweagPQ1cPHM+ZnL5UxEvu/5+KVCbYUAu A02+hAr4IjsQE0/L0LHYkquIjZaiDx37bPqjAJ5rTZhMZNg4POUVAh7VFxNE6iTXzHM6 zJy//bDUVNgBOgEaASrKXQnm8zv7drwn0P5jpx19MsHaRZKs5bOkZ/N7AZNE2mNVfH8+ btccCQZsH4y6UyzXdJ5tmFUYNJeGakqi1UIKWN0Rj+82j+r1ahtVZZoHQNvY9iwR7h8v mBIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=6m5EHrFngIj7a8PPgOziSOXfTBY72BssfH/5Kk6E1D4=; b=AI32kE+In1jTsE6FFaO8RWkqdIKt/UAfYhanaimH+cwNTwYENqzH8GD0Z7sdMBrha5 sKV20JTfLykhvgiRvq5rWTFWDeHZjJH4wNhm+0m32XHQdvEZGPUf1GRCfL2ZdaP9pD5H SIe2KRTld7WMAXUEDcdtxrh0OQIe9TLC5nYSPI4odK0Nb0cs3LaV+135vkQWaGinhWQv HIQXuNN/sgD+6Uv5J8o8GzRCTP9fUiT91M9jIgLmRdJR/ci0/7cclTLhfRgK+Go9qGGt f8sZxduIOH4jEe/qeQBNO01G2dz++5viJ2iX7XfTTH22lfZ/a5LkFfdZTKSjZucvev7c 0QPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PVJfNSNm; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id p7-20020a056a000b4700b0050d332b93b2si1278582pfo.18.2022.04.27.03.36.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 03:36:23 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PVJfNSNm; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 38FCC3D4925; Wed, 27 Apr 2022 02:49:41 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356803AbiD0Blt (ORCPT + 99 others); Tue, 26 Apr 2022 21:41:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356792AbiD0Bls (ORCPT ); Tue, 26 Apr 2022 21:41:48 -0400 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07487FDD3C for ; Tue, 26 Apr 2022 18:38:39 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id p12so630327lfs.5 for ; Tue, 26 Apr 2022 18:38:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6m5EHrFngIj7a8PPgOziSOXfTBY72BssfH/5Kk6E1D4=; b=PVJfNSNmwOFSwuRQYJl7lRIWs85Ihb8IB/CXKjJ/hTifHzTqyOwGYGtunthhHXZyNq 9Xv2EAynR4aE6fg/gYDTv/fNdk0R7qDP/SZopBaqX1/La+/4OnlVTbmohoFdfgfyJYas v/wEOvwinXJN9jziMsAEYFq5T/nSePXu2/zVTVZjFDPtc9G85zITyQBUjCbM26SekN9w NipTfo/DiPMzDOAZHukq7Of5Za+PbVBkGmjrRII9HD1qNojrTAgMbI03vPYHTJVr9fLr vkXG5DbfKIX0Z3o5d3xmGrtqWZBVcI1KCcUzvLiPPF1BhlVwXolmPc7AhO5nP1DSasXZ IlIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6m5EHrFngIj7a8PPgOziSOXfTBY72BssfH/5Kk6E1D4=; b=nDGD5m4/Pc72CPvrrmArqLyKwk+FyaP6k55HWfRoFv9MPGUa8unDF2Yjj8EUBysDJT 6gc+0dztZ7YdF0+PwTJPF4O7fT9hq617tdGBROLmCjof5WxKdqsSWs6IzkfegYXQcYiS yZOPIhfuE6N1mU4A9ygqhgT8dp8UoxIq/i1zC081Gk1KDJN7aQowMkdw3V5a8AqzJuKD tMxYbGlyv/usc1awQFpLxcY9yZv3wiQj1p1y7FmL7mACLbrdMsdi8x3vmclu11Iw1RYc +kYQts9dlxe6SlwnMubN9cpXaFEtKUAJ9M2SLARg27LtRGPuJiTmQfnFobFfyZBGeSoK vqrQ== X-Gm-Message-State: AOAM531A64OSvwL+AGGnzXhEtCrNS40A7S9ygl0aH7fjqMq/G6SyA3uk GDMhI9mxN8qSojIWiMVpDJDys6ms6ViJ761uP40= X-Received: by 2002:a05:6512:13a1:b0:448:887e:da38 with SMTP id p33-20020a05651213a100b00448887eda38mr19011317lfa.298.1651023517177; Tue, 26 Apr 2022 18:38:37 -0700 (PDT) MIME-Version: 1.0 References: <20220407051932.4071-1-xuewen.yan@unisoc.com> <20220420135127.o7ttm5tddwvwrp2a@airbuntu> <20220421161509.asz25zmh25eurgrk@airbuntu> <20220425161209.ydugtrs3b7gyy3kk@airbuntu> <20220426092142.lppfj5eqgt3d24nb@airbuntu> In-Reply-To: <20220426092142.lppfj5eqgt3d24nb@airbuntu> From: Xuewen Yan Date: Wed, 27 Apr 2022 09:38:26 +0800 Message-ID: Subject: Re: [PATCH] sched: Take thermal pressure into account when determine rt fits capacity To: Qais Yousef Cc: Xuewen Yan , dietmar.eggemann@arm.com, lukasz.luba@arm.com, rafael@kernel.org, viresh.kumar@linaro.org, mingo@redhat.com, peterz@infradead.org, vincent.guittot@linaro.org, rostedt@goodmis.org, linux-kernel@vger.kernel.org, di.shen@unisoc.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE autolearn=no 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: X-Mailing-List: linux-kernel@vger.kernel.org > > > The best (simplest) way forward IMHO is to introduce a new function > > > > > > bool cpu_in_capacity_inversion(int cpu); > > > > > > (feel free to pick another name) which will detect the scenario you're in. You > > > can use this function then in rt_task_fits_capacity() > > > > > > diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c > > > index a32c46889af8..d48811a7e956 100644 > > > --- a/kernel/sched/rt.c > > > +++ b/kernel/sched/rt.c > > > @@ -462,6 +462,9 @@ static inline bool rt_task_fits_capacity(struct task_struct *p, int cpu) > > > if (!static_branch_unlikely(&sched_asym_cpucapacity)) > > > return true; > > > > > > + if (cpu_in_capacity_inversion(cpu)) > > > + return false; > > > + > > > min_cap = uclamp_eff_value(p, UCLAMP_MIN); > > > max_cap = uclamp_eff_value(p, UCLAMP_MAX); > > > > > > You'll probably need to do something similar in dl_task_fits_capacity(). > > > > > > This might be a bit aggressive though as we'll steer away all RT tasks from > > > this CPU (as long as there's another CPU that can fit it). I need to think more > > > about it. But we could do something like this too > > > > > > diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c > > > index a32c46889af8..f2a34946a7ab 100644 > > > --- a/kernel/sched/rt.c > > > +++ b/kernel/sched/rt.c > > > @@ -462,11 +462,14 @@ static inline bool rt_task_fits_capacity(struct task_struct *p, int cpu) > > > if (!static_branch_unlikely(&sched_asym_cpucapacity)) > > > return true; > > > > > > + cpu_cap = capacity_orig_of(cpu); > > > + > > > + if (cpu_in_capacity_inversion(cpu)) > > > > It's a good idea, but as you said, in mainline, the > > sysctl_sched_uclamp_util_min_rt_default is always 1024, > > Maybe it's better to add it to the judgment? > > I don't think so. If we want to handle finding the next best thing, we need to > make the search more complex than that. This is no worse than having 2 RT tasks > waking up at the same time while there's only a single big CPU. One of them > will end up on a medium or a little and we don't provide better guarantees > here. I may have misunderstood your patch before, do you mean this: 1. the cpu has to be inversion, if not, the cpu's capacity is still the biggest, although the sysctl_sched_uclamp_util_min_rt_default =1024, it still can put on the cpu. 2. If the cpu is inversion, the thermal pressure should be considered, at this time, if the sysctl_sched_uclamp_util_min_rt_default is not 1024, make the rt still have chance to select the cpu. If the sysctl_sched_uclamp_util_min_rt_default is 1024, all of the cpu actually can not fit the rt, at this time, select cpu without considering the cap_orig_of(cpu). The worst thing may be that rt would put on the small core. I understand right? If so, Perhaps this approach has the least impact on the current code complexity. Thanks! BR --- xuewen