From patchwork Fri Oct 28 06:42:16 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: 12106 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp659098wru; Thu, 27 Oct 2022 23:44:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM74XUVc8j8FFX59R3TD4hegAoEp1mXzbtdfkUll5b5N6s0Zn93WzTqe9OymlsTjsF9UYFCN X-Received: by 2002:a17:903:22cb:b0:186:e07d:9f1f with SMTP id y11-20020a17090322cb00b00186e07d9f1fmr11945343plg.2.1666939479889; Thu, 27 Oct 2022 23:44:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666939479; cv=none; d=google.com; s=arc-20160816; b=lGTc4aWfT8+EBR2OSh2u8JdvW4O9VgYEYdcyY0lxEZeLMqqRGx+S25yRBzIbdznX7K IzHih77LwTqdygCDNXnSiwrWJSuoT7vARyQWSqNyk7Bgt3zR0BbOT9Rw8Un97pYZe8kI YIE/+rLmvF2S1FNKfNI+XQdI4o0xXl8Fl+w1W185hL9vJv7QMr4r+PWh3+RpjgQiodGh R7w3eYQ3jTukict+bSN8F52l6j+COh2PuNB/Ku6CKBMjAFS/oFLKXvMM1v4bSLknbGzr Hh3J2NldZt0j2L+7xmYIDl/mLf4bU8h4jAWJ1aH5mQose4aZXxYMDfxPkYF/88co/USF V9uw== 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=HyeRwTx9QE2PvrbjNs8IROLnWS2slvMmLoZ1ptritHY=; b=jwxoUeE42o3lVMQkrul3qfYqvLfsVNn3j7lhCCud99/z5WbfH1qKQ/WolFS5n4Jhow nbHTiliy7DQzSazNXhYdHCMm+LnfeY7+s20mlAL2Q294XKFnZq3hrHXSKNvAYw/qBOUB AltAZeob0RqWExhtqmtYrKWSOtl47JtCkqzySRm351xYfpw7AhwMngJeUdcmhunx5+Si h564y738KIxUD9hhM+2TKUafOiuOCGsi1mq8ZB+G8CzHJZ9HuZT3ra2MGm4lViRZtDaJ IhT5Kr1m7SF6zEwABrWuaCwtZNvDUe4Cl4dWmTJV9HwsdDOx2Ps4j80713pTvZHn1+fM alNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=tONwv+eY; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 s38-20020a635266000000b00460f2778434si4177042pgl.652.2022.10.27.23.44.27; Thu, 27 Oct 2022 23:44:39 -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=tONwv+eY; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S229891AbiJ1Gn5 (ORCPT + 99 others); Fri, 28 Oct 2022 02:43:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229954AbiJ1GmW (ORCPT ); Fri, 28 Oct 2022 02:42:22 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 681B91BA1F4; Thu, 27 Oct 2022 23:42:19 -0700 (PDT) Date: Fri, 28 Oct 2022 06:42:16 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666939337; 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=HyeRwTx9QE2PvrbjNs8IROLnWS2slvMmLoZ1ptritHY=; b=tONwv+eYyYe+WRYSNNannwL0fBDteHu9Ty9WMhwj1XUV9kU/nrcD3C/SQqINAMfli939et 0A9QYf6+U0GKUoBt3I/0f9vYQvdPg55Wjin/l/mhvZom55A9NvlBJU3zjOhc/gi5bZ9S8/ Rfl/WfRhhlRljtmfhbeXw/DpR0rvSFyXU2ue3Vq/mwfq/tDP63yjxZt6XJrttgW2L7cvfK tPn0ZjQb/oTC56VLZoR6GoJfG8cfblPhNMHRFNPz9tdocHvZb39V+VWnpvrGte0jMv7ncU V/7Du6uE+EWfGiDQ6blR2aILox+i8f2t1P00rSFk85WcMJWaLzWs88k3j+0YrQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666939337; 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=HyeRwTx9QE2PvrbjNs8IROLnWS2slvMmLoZ1ptritHY=; b=vBrUM9YFgM3i99e64u5hgUj0NSVawCqLJyB4s03uEKLV3xxDsaVmczYfULvsfIkw6BUZ5k 0NPJzh3tZ4WLuWAg== 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/fair: Consider capacity inversion in util_fits_cpu() Cc: Qais Yousef , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220804143609.515789-10-qais.yousef@arm.com> References: <20220804143609.515789-10-qais.yousef@arm.com> MIME-Version: 1.0 Message-ID: <166693933665.29415.17740207940084118097.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?1747912731887866977?= X-GMAIL-MSGID: =?utf-8?q?1747912731887866977?= The following commit has been merged into the sched/core branch of tip: Commit-ID: aa69c36f31aadc1669bfa8a3de6a47b5e6c98ee8 Gitweb: https://git.kernel.org/tip/aa69c36f31aadc1669bfa8a3de6a47b5e6c98ee8 Author: Qais Yousef AuthorDate: Thu, 04 Aug 2022 15:36:09 +01:00 Committer: Peter Zijlstra CommitterDate: Thu, 27 Oct 2022 11:01:20 +02:00 sched/fair: Consider capacity inversion in util_fits_cpu() We do consider thermal pressure in util_fits_cpu() for uclamp_min only. With the exception of the biggest cores which by definition are the max performance point of the system and all tasks by definition should fit. Even under thermal pressure, the capacity of the biggest CPU is the highest in the system and should still fit every task. Except when it reaches capacity inversion point, then this is no longer true. We can handle this by using the inverted capacity as capacity_orig in util_fits_cpu(). Which not only addresses the problem above, but also ensure uclamp_max now considers the inverted capacity. Force fitting a task when a CPU is in this adverse state will contribute to making the thermal throttling last longer. Signed-off-by: Qais Yousef Signed-off-by: Peter Zijlstra (Intel) Link: https://lore.kernel.org/r/20220804143609.515789-10-qais.yousef@arm.com --- kernel/sched/fair.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 4c4ea47..919d016 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4465,12 +4465,16 @@ static inline int util_fits_cpu(unsigned long util, * For uclamp_max, we can tolerate a drop in performance level as the * goal is to cap the task. So it's okay if it's getting less. * - * In case of capacity inversion, which is not handled yet, we should - * honour the inverted capacity for both uclamp_min and uclamp_max all - * the time. + * In case of capacity inversion we should honour the inverted capacity + * for both uclamp_min and uclamp_max all the time. */ - capacity_orig = capacity_orig_of(cpu); - capacity_orig_thermal = capacity_orig - arch_scale_thermal_pressure(cpu); + capacity_orig = cpu_in_capacity_inversion(cpu); + if (capacity_orig) { + capacity_orig_thermal = capacity_orig; + } else { + capacity_orig = capacity_orig_of(cpu); + capacity_orig_thermal = capacity_orig - arch_scale_thermal_pressure(cpu); + } /* * We want to force a task to fit a cpu as implied by uclamp_max.