Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp357436imn; Thu, 4 Aug 2022 08:37:36 -0700 (PDT) X-Google-Smtp-Source: AA6agR5NZYevYfcsPrJXDqxAXhcmWOPrwdpBdnoXyGqHWoDf/q1dCejilnheku6KY6ZAQEQxpwrd X-Received: by 2002:a17:90a:b785:b0:1f1:be59:a607 with SMTP id m5-20020a17090ab78500b001f1be59a607mr2688082pjr.84.1659627456596; Thu, 04 Aug 2022 08:37:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659627456; cv=none; d=google.com; s=arc-20160816; b=rnf8YwzbNxnGruLILA1fwNA99GljAz7moQFCI+d7X8W2uhOo2bq11Zoy3SZGmGkhLA GZ4ZfCnUc9+oLnVleZKnlBCO5KQss/QKV1R3MwePAxT8GT5s8oFCE6Lc0R4lGO9668dV JBGfdBpNS8Qu6oSndDtT3FMUz3FykINg3soNCNx2BRfmmESBs1p06QEj5ZmZPMLRLE17 KUi9bzUg3ooDX8V/pZILPD3cjDCdmWU5ArJVFJVPDBXUAh5KrLyVDf8GiTPmjJCM65O2 Vp2SWyXtS1rWA2DKID+bQHd7BVOrR3slX8iCb4/L5ru1AJQpIUQus5W0HJBx/n4EYRQ0 6Uzg== 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=+6biTyXMomwneDqxc9Jv11rXn9zjn4Fend9snpzK67o=; b=fg8DvDSJwm+sRToKzqQzE7J84lrWEkQOdIfdz93biSIeaIgPrzJ+0WAG47Y4MYfGbt dKZFaOVjo0NYLx8bvul7isKSj+B8KdLIZpeBGDqPLT5OatpSymQUJdccjKpMsEwvEL5O DkxYtFcsZP4y1/aKk3wm1iM2D8fx3i2eF2ZtnsoJjyx/dAS20B9Tz87mY9LqXYYdvivN kkD6T3rM35QycdxMEwK12QW5Bqr+C6PwarQwyUaAOO68kuyLhj3/MCZ+k084lbP8E5b6 xhTF8Ms1w3EMeLfOXaTlsKiiyT6GwLsDE4U5vUNGPL08/KHdoRW3uVVVvlWN06fEgjNx 6bUg== 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 p17-20020a631e51000000b00415d29fb2ccsi69129pgm.625.2022.08.04.08.37.22; Thu, 04 Aug 2022 08:37:36 -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 S240009AbiHDOhI (ORCPT + 99 others); Thu, 4 Aug 2022 10:37:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239852AbiHDOgv (ORCPT ); Thu, 4 Aug 2022 10:36:51 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 764DD49B50 for ; Thu, 4 Aug 2022 07:36:49 -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 E2E4111FB; Thu, 4 Aug 2022 07:36:49 -0700 (PDT) Received: from localhost.localdomain (unknown [10.57.10.177]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B68793F73B; Thu, 4 Aug 2022 07:36:47 -0700 (PDT) From: Qais Yousef To: Ingo Molnar , "Peter Zijlstra (Intel)" , Vincent Guittot , Dietmar Eggemann Cc: linux-kernel@vger.kernel.org, Xuewen Yan , Lukasz Luba , Wei Wang , Jonathan JMChen , Hank , Qais Yousef Subject: [PATCH v2 6/9] sched/uclamp: Make cpu_overutilized() use util_fits_cpu() Date: Thu, 4 Aug 2022 15:36:06 +0100 Message-Id: <20220804143609.515789-7-qais.yousef@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220804143609.515789-1-qais.yousef@arm.com> References: <20220804143609.515789-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 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 38cf56ade66d..4c3a5240d7e3 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5807,7 +5807,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