Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp13487263rwb; Sun, 27 Nov 2022 06:29:55 -0800 (PST) X-Google-Smtp-Source: AA0mqf6o2i7kmfkL02iUNA8zOVOoBQbU7AZ+xx1ImSVFu0RSFBppjGv9TELJtpuVzK9XQJ1WWrUm X-Received: by 2002:a17:90a:bf8c:b0:218:e311:d48f with SMTP id d12-20020a17090abf8c00b00218e311d48fmr22854170pjs.163.1669559394841; Sun, 27 Nov 2022 06:29:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669559394; cv=none; d=google.com; s=arc-20160816; b=SEskOzVVNNeskv3xxXkWhC9xhjiyvdK1X2EWolLpQ5Cycq/YjkGNpsF6/Q9gSgziwI S1v3jioxovAfOi5VaAOvhFbw7lFG6wu79IE4i/vhrpWLX8bnInPhyGscd7sIdJ+LBnqY 2FJQSCS55gbHqiL3y0FFTK2amBQsZa3brLkLDIUCXdQ3ou/FEpJUXGCSDOC47JBlVxme vqlBBuxHsjHjTM1LZd2gbSM7lT3vx6WxB4sF23/yE8P4UYYUypkCNFsqgKreqBMluPwp wVCcEZqq4PTU6kpW6p+gnNtbc6dT7FHsIVob0ZQYi+84AE3z3V6OiB8tG9Gd/xY2IThk p+5g== 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 :dkim-signature; bh=tgcAWBJdxBqHoNuM/m9bsANWdisyh2T9vffT0LuLN3Y=; b=uSW/CLyakRAAs5cww8nDXmCRtuWJ4cyyDPBMthIHmMt/jwkvmXKf8avmFjdx9r9tuX WF2/C5rl957TNkvNRC2MJz1TS3nezt4EM7+t2b6H7e7hCmOXEIo/EGfKwF55mgWaPMkj mgoqBaM9YKOUX+vAZVt1mSQhcdd+rzua19UkYYRZwx+u9v3HoUIFrQQ86GlXStBwIpsl lB2C8ZRl+ksblDylmPHo7N5WzkTP4KxWnSJGFdSoXhG2cb/NKBJ0sjDLY36m4dC+scaU fZ7j6H8g5ofgslmu1GooYFINvL6WW6M+WtDkn0kFpDASzy8oyvcelFa7gDYX5sd8S/PA AM1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@layalina-io.20210112.gappssmtp.com header.s=20210112 header.b=aYJrxtYC; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d17-20020a631d51000000b004615836deeasi9858037pgm.860.2022.11.27.06.29.44; Sun, 27 Nov 2022 06:29:54 -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=@layalina-io.20210112.gappssmtp.com header.s=20210112 header.b=aYJrxtYC; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229637AbiK0OSP (ORCPT + 85 others); Sun, 27 Nov 2022 09:18:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229629AbiK0OSH (ORCPT ); Sun, 27 Nov 2022 09:18:07 -0500 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF525DF2B for ; Sun, 27 Nov 2022 06:18:06 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id a11-20020a05600c2d4b00b003cf6f5fd9f1so6700757wmg.2 for ; Sun, 27 Nov 2022 06:18:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tgcAWBJdxBqHoNuM/m9bsANWdisyh2T9vffT0LuLN3Y=; b=aYJrxtYCrDMcXnPEqawG6vMJITTsdHOlN+f1gP9rE7xYHbZlt5xSW1RpwdA2HATted XX2GO8LtjHfU7JomPTjpJCOMM19wJ5l6Hr3qC2NDPXb68FLQwrOhD/dSaTGhUIfigajq txiQXB9YO7nujtiCbwfr9rYJCnvwCtXg8oj+4cjqZc21VA6CsPF/YOx4oSzISh94IDMU uuTykuXHOIPRJYH7YMef8gWPKeU5Lh8Nf8a0aq3ElWBJbS19LnaTFP4ARYWkXZZ1KcAm qYPXgF9KuiCzxTDxOGktcwnSXEq+LqX/pop1jXlVwoxkH1OG7ThNYiJU9VAthZgUdWJe qa7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tgcAWBJdxBqHoNuM/m9bsANWdisyh2T9vffT0LuLN3Y=; b=gad8XbOALDNI24AIeBsnT9GPTDPAgv917dnmvhszUe30RYi2s78NnpbsGtuNmE3jIe 3daoWkG7t93oUKT2sZFsvZHOrwhGQbEyNaE0l3GZY7ynxcw1zQCrry0/JDqjfeMmXtzB ReKhXVQumuutLQOOe3gvC2dGvRJ088Ya8HfrKwSvim1r+YKw6TKmeTOf1ptADxFWqumW Id5v4oJusBEQ2+sxsmRdT8Zn1w38gki0cDjAMZmeHaEWghBc68t7figPYxB2GpZAz1N9 yW2fETYXPuakojFEsonP/qFR1pEU2mRR9JPvSyS2okash8E8Cap2bshu7OB58XbXoI28 TM2A== X-Gm-Message-State: ANoB5pnVh0IIfkbWmG6Bz3cKV1ixsYGokqpRFduce1G2VLJ70TnGk3SW SAgO5P9d9TkZ9IPj6p3WAqAyqg== X-Received: by 2002:a05:600c:384f:b0:3cf:9377:c76f with SMTP id s15-20020a05600c384f00b003cf9377c76fmr22582044wmr.189.1669558685424; Sun, 27 Nov 2022 06:18:05 -0800 (PST) Received: from localhost.localdomain (host86-130-134-87.range86-130.btcentralplus.com. [86.130.134.87]) by smtp.gmail.com with ESMTPSA id l1-20020a05600c4f0100b003c6f3f6675bsm17109757wmq.26.2022.11.27.06.18.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Nov 2022 06:18:05 -0800 (PST) From: Qais Yousef To: Ingo Molnar , Peter Zijlstra , Vincent Guittot , Dietmar Eggemann , "Rafael J. Wysocki" , Viresh Kumar Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Lukasz Luba , Wei Wang , Xuewen Yan , Hank , Jonathan JMChen , Qais Yousef Subject: [PATCH 2/3] sched/fair: Fixes for capacity inversion detection Date: Sun, 27 Nov 2022 14:17:41 +0000 Message-Id: <20221127141742.1644023-3-qyousef@layalina.io> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221127141742.1644023-1-qyousef@layalina.io> References: <20221127141742.1644023-1-qyousef@layalina.io> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 Traversing the Perf Domains requires rcu_read_lock() to be held and is conditional on sched_energy_enabled(). rcu_read_lock() is held while in load_balance(), add an assert to ensure this is always the case. 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) --- kernel/sched/fair.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 89dadaafc1ec..7c0dd57e562a 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -8856,16 +8856,22 @@ 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); rq->cpu_capacity_inverted = 0; + SCHED_WARN_ON(!rcu_read_lock_held()); + 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); -- 2.25.1