Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp944576iog; Wed, 29 Jun 2022 13:36:10 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v1iedpA/FsQoWQiZC+vy6zo0IfNuUaq5bsI7H6kKyv7SOWx5H4X4QqTfNe/f9x0UxmuZ0H X-Received: by 2002:a05:6a00:1a48:b0:522:9716:4e0a with SMTP id h8-20020a056a001a4800b0052297164e0amr10687375pfv.22.1656534969897; Wed, 29 Jun 2022 13:36:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656534969; cv=none; d=google.com; s=arc-20160816; b=zg0BCJUl+FulPrQi0WeNCTLoJG443SJwptg+pa6jm2oGd33g00VKUh0j99uxZoe+DX BuFFliY1No/U58tELoQGLS9cec188531iyjXKd+awjWLQFlm4+cBAbwcTWR26ooGpy78 OrSrOUKl1twnWZyEX2FEb3VIb/0AJaubcBP2l1uShCt5mk0iCJgsapwuqQjmPAyDNqiK 9eGLIDj/BBmyZrwQKO8UnHzUGC3NXFO+F6jCRj6lU9L5/IrXRZg9SuKYkXE3XvnfwMYJ V26DZNkvbO6k4CGJ75UNcQfnVtNQBmrioDEVemtr0GMueTY64EYDiSGSLQVXucO9qa08 ufxw== 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; bh=7JTCimHbkx0ETNIq0zFx45AiJ1Iw2vztTrR5gyEEnGg=; b=MShEm9vCLk1UcPw11k3o834youvL5Qq4r5HJRfpve6IOnUHsCb1nBiNi3ImaSTZKIc HD2Fhln3susnEcBRGKOsgtPpaDJOyWmin9XGDmq3D+lW/wHP4E11pemwKezEGsjohGO8 vr6MwU5FuLghsxaKU4u84C05KsKha84LvwVlpvSFWDDN1TD+iHEkH28A2HjokbbcJH+P WQTxmBx6+P7KllfNzAs3jWVb2vTVecSTp8zgPFgXpmBgkt6drmhZKJSmUryjeHZs50F7 3xsEFi7cb6hzlrefGJpIPr6xIrrh6EEde5FMK+6uVbKGZEgEMPNmJs3QvdYThTxEc8eK Zp+w== 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:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m7-20020a6545c7000000b0040cf7280474si21410427pgr.75.2022.06.29.13.35.56; Wed, 29 Jun 2022 13:36:09 -0700 (PDT) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231429AbiF2TsT (ORCPT + 99 others); Wed, 29 Jun 2022 15:48:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231425AbiF2TsR (ORCPT ); Wed, 29 Jun 2022 15:48:17 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CFF801CB00 for ; Wed, 29 Jun 2022 12:48:16 -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 D8CD81480; Wed, 29 Jun 2022 12:48:16 -0700 (PDT) Received: from e107158-lin.cambridge.arm.com (e107158-lin.cambridge.arm.com [10.1.197.38]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 622BA3F792; Wed, 29 Jun 2022 12:48:15 -0700 (PDT) From: Qais Yousef To: Ingo Molnar , "Peter Zijlstra (Intel)" , Vincent Guittot , Dietmar Eggemann Cc: linux-kernel@vger.kernel.org, Xuewen Yan , Wei Wang , Jonathan JMChen , Hank , Qais Yousef Subject: [PATCH 6/7] sched/uclamp: Make cpu_overutilized() use util_fits_cpu() Date: Wed, 29 Jun 2022 20:46:31 +0100 Message-Id: <20220629194632.1117723-7-qais.yousef@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220629194632.1117723-1-qais.yousef@arm.com> References: <20220629194632.1117723-1-qais.yousef@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org So that it is now uclamp aware. This fixes a major problem of busy tasks capped with UCLAMP_MAX keeping the system in overutilized state which disables EAS and leads to wasting energy in the long run. Without this patch running a busy background activity like JIT compilation on Pixel 6 causes the system to be in overutilized state 74.5% of the time. With this patch this goes down to 9.79%. It also fixes another problem when long running tasks that have their UCLAMP_MIN changed while running such that they need to upmigrate to honour the new UCLAMP_MIN value. The upmigration doesn't get triggered because overutilized state never gets set in this state, hence misfit migration never happens at tick in this case until the task wakes up again. Fixes: af24bde8df202 ("sched/uclamp: Add uclamp support to energy_compute()") Signed-off-by: Qais Yousef --- kernel/sched/fair.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 2cfb4efecbc2..499ef7a7288c 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5744,7 +5744,10 @@ static inline void hrtick_update(struct rq *rq) #ifdef CONFIG_SMP static inline bool cpu_overutilized(int cpu) { - return !fits_capacity(cpu_util_cfs(cpu), capacity_of(cpu)); + unsigned long rq_util_min = uclamp_rq_get(cpu_rq(cpu), UCLAMP_MIN); + unsigned long rq_util_max = uclamp_rq_get(cpu_rq(cpu), UCLAMP_MAX); + + return !util_fits_cpu(cpu_util_cfs(cpu), rq_util_min, rq_util_max, cpu); } static inline void update_overutilized_status(struct rq *rq) -- 2.25.1