From patchwork Fri Jan 13 12:08:48 2023 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: 43217 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp234847wrt; Fri, 13 Jan 2023 04:15:43 -0800 (PST) X-Google-Smtp-Source: AMrXdXtcMZLdPRUdj8LdTz2ArDWBU3i96gmyynsFGB+9p0AvZm3TnhOtc8ZPXNJHFIoXj2nCKGMf X-Received: by 2002:a17:902:7288:b0:193:24bf:344d with SMTP id d8-20020a170902728800b0019324bf344dmr20566853pll.57.1673612143490; Fri, 13 Jan 2023 04:15:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673612143; cv=none; d=google.com; s=arc-20160816; b=zE0tv2xGECau0Cg9wnMfIhiuOUEDOgaBS70NUye3AQ61HEXjsFYBnrqcCtAAA8wRYQ huIvEnxy6nokA+rSJUuMS13nlXYg9y7PqncouEfcneyETSXSoptkkiDa+vd512qTPoE+ DqBc2lfx46zrH1iTpvQa6Fv7eathdnxJ0ERf4MzkSd2baaoCVtyV/eRbMI6+WLpDs6+X 2FQn0glky9df++Hq7CIFvAwQyLojmN8/T66gkTrxx8KcVYUgnJlbZ+/rSnh/3Z4eMX0v h2OjwwVNOVhql0hHncwtj7yunEhvXualn669pHxSxyEhSg5l1Qc6AGB2ZnknuAWQg3Ti 9fFw== 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=p/Ic1iHz7HOZXaYuCXWJmrVkuygPLmdoT5X74IVs4F4=; b=UDQjlt1b5xprRV0Hny4Ymwwfi2hC+7zQ2Wa2an3aaRxIKe9HJWA7Fj9bAOVgbf+Rkn aSngD40doOPoDDuOK1klPKUqwtCZWCwQxzzLYctWXuL4Ze4zGq70RFsHKOko8n2MVMl5 STTgnmbXSEwk2i8/c+tNHlt4ya+L286d5zIR3g3x38+PTRm7hX+9hN4Nt2e3o7r97f69 d3M+7m+jJXHO1yAhF1o/H2D1sKs4Bs3Kv+1cI52ADBI8LIuxJPS57bOEaNPhKX2zXe5t os2kryMCOc8K84l2LVMEx58yIqeVUWgejJXGAq4J+LKxtPZHEfGP5lMhc2EC8K0nipwF ieUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="tHfH//SC"; 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 b21-20020a170902d89500b001897bfc97fesi9895634plz.54.2023.01.13.04.15.31; Fri, 13 Jan 2023 04:15:43 -0800 (PST) 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="tHfH//SC"; 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 S241331AbjAMMPO (ORCPT + 99 others); Fri, 13 Jan 2023 07:15:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240773AbjAMMOE (ORCPT ); Fri, 13 Jan 2023 07:14:04 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D731C39F85; Fri, 13 Jan 2023 04:08:51 -0800 (PST) Date: Fri, 13 Jan 2023 12:08:48 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1673611729; 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=p/Ic1iHz7HOZXaYuCXWJmrVkuygPLmdoT5X74IVs4F4=; b=tHfH//SC2gwMwc/gpDl6kaUeJ0/a9ii4zzJ6iAkjsoy8gFyxV0K6GqmOVmWjc7kbk98kqD Syuem4R9u4HONmYTsxbm0DblE3X/AyhlFOWU8lQ5PgU/BEK165etO/1gGEaFCvJJ41AY6b l8jngw5nWxDSroyq6RLBmdD2DpfoMkHaSLFjVDlAPv9PBdVlSFmHhtI8x0JPgi2M2j7F/N F58/a9M/EZ70X9b9lLyO++/SuUO1TJenftGTuLrFT44lugwhR6hejSnQkUgj5/D6W8s5UH eyvf1sYYVRQaKbzzUdjnv2MulPYI8WBgnALLarfmDcM586GMIQbFsGvjKWxFjw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1673611729; 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=p/Ic1iHz7HOZXaYuCXWJmrVkuygPLmdoT5X74IVs4F4=; b=xu7T3dWh3XoitD0n4zxH4ygrNwkPfXafMdSuUsX3gqx6FqwE5m2+GaSfTOztcZHdTd200x aS+gMpJEc+KQcNCA== 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/urgent] sched/fair: Fixes for capacity inversion detection Cc: Dietmar Eggemann , "Qais Yousef (Google)" , "Peter Zijlstra (Intel)" , Vincent Guittot , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230112122708.330667-3-qyousef@layalina.io> References: <20230112122708.330667-3-qyousef@layalina.io> MIME-Version: 1.0 Message-ID: <167361172839.4906.18334832591447660001.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?1754820325435493199?= X-GMAIL-MSGID: =?utf-8?q?1754909526618852730?= The following commit has been merged into the sched/urgent branch of tip: Commit-ID: da07d2f9c153e457e845d4dcfdd13568d71d18a4 Gitweb: https://git.kernel.org/tip/da07d2f9c153e457e845d4dcfdd13568d71d18a4 Author: Qais Yousef AuthorDate: Thu, 12 Jan 2023 12:27:08 Committer: Peter Zijlstra CommitterDate: Fri, 13 Jan 2023 11:40:21 +01:00 sched/fair: Fixes for capacity inversion detection Traversing the Perf Domains requires rcu_read_lock() to be held and is conditional on sched_energy_enabled(). Ensure right protections applied. Also skip capacity inversion detection for our own pd; which was an error. Fixes: 44c7b80bffc3 ("sched/fair: Detect capacity inversion") Reported-by: Dietmar Eggemann Signed-off-by: Qais Yousef (Google) Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Vincent Guittot Link: https://lore.kernel.org/r/20230112122708.330667-3-qyousef@layalina.io --- kernel/sched/fair.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index be43731..0f87369 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -8868,16 +8868,23 @@ static void update_cpu_capacity(struct sched_domain *sd, int cpu) * * Thermal pressure will impact all cpus in this perf domain * equally. */ - if (static_branch_unlikely(&sched_asym_cpucapacity)) { + if (sched_energy_enabled()) { unsigned long inv_cap = capacity_orig - thermal_load_avg(rq); - struct perf_domain *pd = rcu_dereference(rq->rd->pd); + struct perf_domain *pd; + + rcu_read_lock(); + pd = rcu_dereference(rq->rd->pd); rq->cpu_capacity_inverted = 0; for (; pd; pd = pd->next) { struct cpumask *pd_span = perf_domain_span(pd); unsigned long pd_cap_orig, pd_cap; + /* We can't be inverted against our own pd */ + if (cpumask_test_cpu(cpu_of(rq), pd_span)) + continue; + cpu = cpumask_any(pd_span); pd_cap_orig = arch_scale_cpu_capacity(cpu); @@ -8902,6 +8909,8 @@ static void update_cpu_capacity(struct sched_domain *sd, int cpu) break; } } + + rcu_read_unlock(); } trace_sched_cpu_capacity_tp(rq);