Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1934055rwi; Fri, 28 Oct 2022 00:24:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM75LK2O+vDc8kHVdIRgmA3vTiGVK1mhMuzGr7Y+9nMRZcm6AXo56rhLSPHpwlXYVfFXrK+A X-Received: by 2002:a63:5b05:0:b0:460:a6a:ec38 with SMTP id p5-20020a635b05000000b004600a6aec38mr44577156pgb.485.1666941851971; Fri, 28 Oct 2022 00:24:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666941851; cv=none; d=google.com; s=arc-20160816; b=B3pjzWBEU8aGYlZNcmBu+xm97/cNZwoeS/UM+KqSqdkWbRtVRk3Iki8RZhuj9VHDU9 iohnmzfeDmAej/cmfos/rN61Ffe+fH2R8s226mZBTn2Mvahy4gIevCOnG36nlqolu0GI CwPAgrvSNUfAl8ElyV6oeauE/MueZcM5KgCdTuA5CuZnbob+t34aA5eRww7NdtUv10Tu FaEvg7BWc1yNlfC9viF4cnamfbQ3sSgcBFZmDqmpH7AuVnWwqqcAu0KEztTh5UVRfyxx 8U1rjHUL59sfKLYqgm7L/eJ7hYPg5KLOzI8mKBTa6OlYkLvEdgXis3vbT8r/M5E7suUZ kF0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=4fdtyswIlXhZDxIDmJgt5i7Zm70bgRwTXWdCBkV57Us=; b=S0A2bfBUQlljrB1jilS7vmNxEtXwghYBNK7NJsuKqPCDcpbsCL2WQDX475+WRA/tf4 HgsrCcJo9xcaLzhi+MsqZIfqBYn4a+SsI4Cft0fAN2fbqAvbdL8OiS4B4zzCI3Xx3RA8 3nOes5tD4Jnuu+REYstgRM04M4zwbly9+xXragm+3qE5R/axs3djoBaUZX37l4ZSz/g7 hKq1ZZdseZuHCyGQE/ohGPSE2/OnJoetR4hG7TTQq6I22rZKhQ1ZqQ10XhhdJYXdsN6i IW+IogyYCI4gF8Uul5YQEab5/NZug1nVcoK9QLGc65yho3bm2HGLkMsnLnlnoRR7w6fb o1GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=C10mRIHR; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=xN1Ik5I7; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w9-20020a170902904900b0017f792fe3edsi4103461plz.266.2022.10.28.00.24.00; Fri, 28 Oct 2022 00:24:11 -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; dkim=pass header.i=@linutronix.de header.s=2020 header.b=C10mRIHR; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=xN1Ik5I7; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230108AbiJ1GoU (ORCPT + 99 others); Fri, 28 Oct 2022 02:44:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229756AbiJ1Gm3 (ORCPT ); Fri, 28 Oct 2022 02:42:29 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82DAB1BA1D0; Thu, 27 Oct 2022 23:42:22 -0700 (PDT) Date: Fri, 28 Oct 2022 06:42:19 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666939341; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4fdtyswIlXhZDxIDmJgt5i7Zm70bgRwTXWdCBkV57Us=; b=C10mRIHR2YCLtTmPFNj7cxuBXOUzHZCmlSCFDDkzlnCXTf4rZCVRIVfDKcpnIDW66ehqOw n82nJYIX2rRan3e5PCbo6pKmY1UBV2khFnq8Gw2JBGfzSlvpwZqNN7S9luC0NwtKLIeZXw L8PWlnFWEy8zTZI8n+pr4ciwbV+whuvF87LMbiaq0pwJQ6lYHzBRIxQ1+fAd6YrV9T+L55 vnXYLDKf0oxo8L70zyGseUwRYFnAxxKmLdpJTFbxX+pupUz3yPq711/JZMHjk/DFyWDc5z oD3R3HzLPGA4J0r8Ff3PbfMB5tk96kvf1JKM9lo5XVPvSKumJ03CxhUER/dvpg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666939341; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4fdtyswIlXhZDxIDmJgt5i7Zm70bgRwTXWdCBkV57Us=; b=xN1Ik5I78wLn6a06wI8WTjZw5bayeuUxqOWyByS/jXuPwkLjcabpM+ig9dUNXQEKg3Bk0y WyaaentDBRpNMJBw== From: "tip-bot2 for Qais Yousef" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched/uclamp: Make cpu_overutilized() use util_fits_cpu() Cc: Qais Yousef , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220804143609.515789-7-qais.yousef@arm.com> References: <20220804143609.515789-7-qais.yousef@arm.com> MIME-Version: 1.0 Message-ID: <166693933995.29415.10483608660072529451.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/core branch of tip: Commit-ID: c56ab1b3506ba0e7a872509964b100912bde165d Gitweb: https://git.kernel.org/tip/c56ab1b3506ba0e7a872509964b100912bde165d Author: Qais Yousef AuthorDate: Thu, 04 Aug 2022 15:36:06 +01:00 Committer: Peter Zijlstra CommitterDate: Thu, 27 Oct 2022 11:01:19 +02:00 sched/uclamp: Make cpu_overutilized() use util_fits_cpu() 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 Signed-off-by: Peter Zijlstra (Intel) Link: https://lore.kernel.org/r/20220804143609.515789-7-qais.yousef@arm.com --- 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 cabbdac..a0ee319 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5987,7 +5987,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)