From patchwork Fri Oct 28 06:42:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 12111 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp659191wru; Thu, 27 Oct 2022 23:45:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4qkDZxutIGFBoKpyROzm9ktoph0GThAJxggHmjb0Iq8d90NZ3z4doFEZihYiTIwDzxGWKX X-Received: by 2002:a17:90b:2305:b0:213:7a2f:aed8 with SMTP id mt5-20020a17090b230500b002137a2faed8mr6487611pjb.129.1666939500471; Thu, 27 Oct 2022 23:45:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666939500; cv=none; d=google.com; s=arc-20160816; b=wYNnrxU9ROy17GgaGkXslyHkjj293RQmH0pFL1xi+fYufzOzSmae1zscOyXb65MnEB Mv8c/2Nb07mrQoWMORWkH61/6caGO6zyuKmks1fY4Jy0oiFpFiQQnDDMy3MS0NFvUtn4 b7NLPvX88JuU3C1h7JWM3LdtMFfiWAcNecPsCtPIQX//K+UiDM0LB4wykRZ3gdlFKu22 WmloPPDBCZWayN+Z9BdaqBdHyWj+Q2U4d8ycSGZG1BEbSk0oGCLtEcGgvfv7/w/YXwmH 7dblXSJhVrG2MOErAIJXkzKazQH+zWdQzw/BSpjfyLrOms+4c4zS65AZj962EJxxvRrU T3JQ== 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; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y17-20020a17090322d100b00176e21bab6asi5297728plg.118.2022.10.27.23.44.47; Thu, 27 Oct 2022 23:45:00 -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; 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747912753420710549?= X-GMAIL-MSGID: =?utf-8?q?1747912753420710549?= 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)