Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4472641ioa; Wed, 27 Apr 2022 04:45:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3f3+Sun5PEQ6Qvj4dEnc5wqM1NOAgsQaQK4KBs3ORoUwmz1IMb0mTaaF3uhvHpZxkIVaK X-Received: by 2002:a17:90a:ba15:b0:1c6:7873:b192 with SMTP id s21-20020a17090aba1500b001c67873b192mr32598126pjr.76.1651059931616; Wed, 27 Apr 2022 04:45:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651059931; cv=none; d=google.com; s=arc-20160816; b=gyTq0oLW0EpIDMtmNLi58w2uvIqmRil/+KPdNZQnIsYzJHN/grx1pe6AHsA8UIhdat lKsQgtP2pDCI2AR0SfRI6/l9CCAzQ7cl7horA5HOZf3ByFh+LAGLjY1d8zbRLX01Vx9m Uyl8C8kzUFZyoOi6wnXO95Hrm7x2Fpc4OPxsVYqSoH+1eKRRNj0hLuZ4WotWV41TyLGZ +JP0ehnG2OvNKVD8+s6Ath9eT+WpcUO1mTFZUvoXlr0J5rp8d6dRVhuRRhh3hb/DafUJ bZt1P3JurC/JLOn8i13EpPDYyFbR0JDjfpYWYDsvVGCCs4FcWZAkfDLqHMYmTSV87lrX lxsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=9JZObHgs2qzW6PeUmO9shNI4kG87Xv0AlgIjESp7o2c=; b=OMuB2huedO9H2f+z+4mldYI7aXg8crGCuhXzCnMw1u0hIYgwCdyM/JS+DXk61f8lbv UmoBb9jRBhUtjHfBw5/ouixg1odK0loMjXW5xzaAQ0VkURSlUoAX3p9Jl+W8ZV05YVXR oyZT6v2lfg1TzbV0O34Z/M6cnKJ1oJ8d8S6QdW08xUswZB5H8/rLeG76EJQIDperMaM4 NDIjEK88pgsESAiaJkjzZqY0U7RUUd+5Xv5LNcZzVCNpVg4991y9C/pjAvel7CHJRvh+ KqXMda0RVPUL3llFBmBwqyrvYSKfL9IDfvkHCPEZ995Hc1j1jX46qbCY/OBz5MU+k1h8 N5fA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q11-20020a65494b000000b003aa6731b2c4si1290387pgs.581.2022.04.27.04.45.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 04:45:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 96926220EE; Wed, 27 Apr 2022 04:04:21 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232319AbiD0LHI (ORCPT + 99 others); Wed, 27 Apr 2022 07:07:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232218AbiD0LGp (ORCPT ); Wed, 27 Apr 2022 07:06:45 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0CDAE36CE0A for ; Wed, 27 Apr 2022 03:58:47 -0700 (PDT) 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 BB0E5ED1; Wed, 27 Apr 2022 03:58:47 -0700 (PDT) Received: from wubuntu (unknown [10.57.77.199]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 208FF3F5A1; Wed, 27 Apr 2022 03:58:46 -0700 (PDT) Date: Wed, 27 Apr 2022 11:58:44 +0100 From: Qais Yousef To: Xuewen Yan 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 Subject: Re: [PATCH] sched: Take thermal pressure into account when determine rt fits capacity Message-ID: <20220427105844.otru4yohja4s23ye@wubuntu> References: <20220407051932.4071-1-xuewen.yan@unisoc.com> <20220420135127.o7ttm5tddwvwrp2a@airbuntu> <20220421161509.asz25zmh25eurgrk@airbuntu> <20220425161209.ydugtrs3b7gyy3kk@airbuntu> <20220426092142.lppfj5eqgt3d24nb@airbuntu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, 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 On 04/27/22 09:38, Xuewen Yan wrote: > > > > 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. I believe you understood correctly. Tasks that need to run at 1024 when the biggest cpu is in capacity inversion will get screwed - the system can't satisfy their requirements. If they're happy to run on a medium (the next best thing), then their uclamp_min should change to reflect that. If they are not happy to run at the medium, then I'm not sure if it'll make much of a difference if they end up on little. Their deadline will be missed anyway.. Again this is no worse than having two RT tasks with uclamp_min = 1024 waking up at the same time on a system with 1 big cpu. Only one of them will be able to run there. I think tasks wanting 1024 is rare and no one seemed to bother with doing better here so far. But we can certainly do better if need to :-) Thanks -- Qais Yousef