Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp157937rdb; Thu, 1 Feb 2024 05:12:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IHi8n6hT1MtIGwAjDkTFufFK0me9WaX88bc+csylRfuaVyqQ6+LGxE71PUJu3ZWmZYA6pNz X-Received: by 2002:aa7:d816:0:b0:55e:ea35:1da4 with SMTP id v22-20020aa7d816000000b0055eea351da4mr3384120edq.4.1706793151503; Thu, 01 Feb 2024 05:12:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706793151; cv=pass; d=google.com; s=arc-20160816; b=rUb2pIFq1eJuCXx3JDpJoJSm+LZJTKdbQP+akcXtLeFClqetwytcsMMFxu5O/0HX6+ zdi3LlYsJD46MQ8zphA2bMoi6zeSQVKLGC2AignlxopUPyluMdkgSU4VY9iwNe8BEHl3 of0J3Unvj2VepNP7DLLJyVlRezbedcr8wd20OUXckXHsOaGGJIiLvwCC7+otmEyVRV5Y 9knP6CzXNtFs9hu95QK7WB4gHSg8ekVy4HUSuwEXTdu3siEPT9VqLQ5d9FP8+DasFXHg rr9A5h5fSyceDEUN6/Pfak6KakwdUhVlFEftCdPFesUr0CjTY+M04z3v0uzXPswyRsYt HOUA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=uOb9sf3OujVjH18n/gPojKC8sP8H17OoJApcd8mHnGI=; fh=uxaXbTwyeKJjq6UML3+do104YfTiQitGWP35wmJ9Z3I=; b=n7fnMEpGwEesB6JQarKy+Ff0MyWR88nLwdRsb0kcbGcHBWskl7N+torkisjFiwaz+l jQoqDRBn/FmoZOtKh+TjtUBSHWcr48dXfcXhEJBY9HQkVk2L8FtOgZNgtCK6+LcV/ATo 9bIZZbUCjvGira9q9PkZruUsdvjxxplxeTSE/3yNn2wanAlbI4OhDhxp3LQ/N0CCfOlW zWB5bFoKcdzyfG4ApopDIbb1L7wtXgKDhy9kMCnroqZ1//O10j/4CcYxfMdHs5foTdjQ OD5kr5EqPwJPUPNX9iUpZKSB1v47+G9stajnaRpyPEYEtg1Nx7YTYAeZzdits2BP6rI+ k9CA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-48203-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48203-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=1; AJvYcCWalx37M9Tq4yD1QoV++SHaXTt5gGjYp3i8XUE749gzeoKuww6lcsOjCxfuH4wLp3HlBQCPK4j9A2mmfwGmiaBI1UWdL1aV698sPXQrBQ== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id c9-20020a0564021f8900b0055c5c8f107fsi7183879edc.515.2024.02.01.05.12.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 05:12:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48203-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-48203-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48203-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 40FB31F2333C for ; Thu, 1 Feb 2024 13:12:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7732C53381; Thu, 1 Feb 2024 13:12:18 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A4FA88665E for ; Thu, 1 Feb 2024 13:12:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706793138; cv=none; b=LWi6hG2F0E23K4DfSJIgMzgtTZci3zWMCw9gXSk31I8LZKm6eX4Dm9lMoH8C5T6sjntN2Hyp8qO/4XKMbl3Ww9uwRjA9LEVKePDG+kXqaOx7aJ8tyjzLDrgm7KJDf2Vo26QIL2y8HJ2t2ieXB0067v2O/46ou2JwtjZcX6+SSUY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706793138; c=relaxed/simple; bh=fFtMnS0pExRU9XxAc52P1T23Oszmuznw5qpiL99BkH4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uZXS/h9AVZIoGu1bvxoKlS3kaaEG09XjSGrX0XPeeEhv6jO4nSwoSL+BXS68tfmpo0gMhsySc2OIfltwc2+9aG1hjrDCbtQHPonhAag4R8xTu2aFyj8jVOntL39Pb76se+GsHDissJax3JepmtE3IMiOR1gRDQhkUzW/SIgYwy0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A837B11FB; Thu, 1 Feb 2024 05:12:57 -0800 (PST) Received: from e130256.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C1AC63F762; Thu, 1 Feb 2024 05:12:12 -0800 (PST) From: Hongyan Xia To: Ingo Molnar , Peter Zijlstra , Vincent Guittot , Dietmar Eggemann , Juri Lelli , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider Cc: Qais Yousef , Morten Rasmussen , Lukasz Luba , Christian Loehle , linux-kernel@vger.kernel.org, David Dai , Saravana Kannan , Hongyan Xia Subject: [RFC PATCH v2 1/7] Revert "sched/uclamp: Set max_spare_cap_cpu even if max_spare_cap is 0" Date: Thu, 1 Feb 2024 13:11:57 +0000 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Hongyan Xia That commit creates further problems because 0 spare capacity can be either a real indication that the CPU is maxed out, or the CPU is UCLAMP_MAX throttled, but we end up giving all of them a chance which can results in bogus energy calculations. It also tends to schedule tasks on the same CPU and requires load balancing patches. Sum aggregation solves these problems and this patch is not needed. This reverts commit 6b00a40147653c8ea748e8f4396510f252763364. Signed-off-by: Hongyan Xia --- kernel/sched/fair.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index b803030c3a03..d5cc87db4845 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7978,10 +7978,11 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu) for (; pd; pd = pd->next) { unsigned long util_min = p_util_min, util_max = p_util_max; unsigned long cpu_cap, cpu_thermal_cap, util; - long prev_spare_cap = -1, max_spare_cap = -1; + unsigned long cur_delta, max_spare_cap = 0; unsigned long rq_util_min, rq_util_max; - unsigned long cur_delta, base_energy; + unsigned long prev_spare_cap = 0; int max_spare_cap_cpu = -1; + unsigned long base_energy; int fits, max_fits = -1; cpumask_and(cpus, perf_domain_span(pd), cpu_online_mask); @@ -8044,7 +8045,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu) prev_spare_cap = cpu_cap; prev_fits = fits; } else if ((fits > max_fits) || - ((fits == max_fits) && ((long)cpu_cap > max_spare_cap))) { + ((fits == max_fits) && (cpu_cap > max_spare_cap))) { /* * Find the CPU with the maximum spare capacity * among the remaining CPUs in the performance @@ -8056,7 +8057,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu) } } - if (max_spare_cap_cpu < 0 && prev_spare_cap < 0) + if (max_spare_cap_cpu < 0 && prev_spare_cap == 0) continue; eenv_pd_busy_time(&eenv, cpus, p); @@ -8064,7 +8065,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu) base_energy = compute_energy(&eenv, pd, cpus, p, -1); /* Evaluate the energy impact of using prev_cpu. */ - if (prev_spare_cap > -1) { + if (prev_spare_cap > 0) { prev_delta = compute_energy(&eenv, pd, cpus, p, prev_cpu); /* CPU utilization has changed */ -- 2.34.1