From nobody Wed Dec 17 17:44:49 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 353F8205E36 for ; Tue, 4 Mar 2025 14:23:29 +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=1741098212; cv=none; b=jWBBZcCu9nBN5xTRPHEWWj53Vzaqt5L7X6X1IUNjKnOBrOGIsghNjFuXfFxWtc74B9ACn3gGHgBhcRKOjfIx3PXBTJmPbnns5nTLuvqywi/pg3jGZzuvqZo/TCgAOroFx22ioyBneKW/d08FDMEqf+kymY5XjuDsThxGPjUuk+k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741098212; c=relaxed/simple; bh=Hq2UWhVleNV3rRPtc00pqkqQi0ddlRTPYKZ0ga1YvZQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cLbqO4ompGwNPGuIiDuwgcKh5n8Gg/CB8nREj6gPjg90sNwnSrwd7i6KihgVsHgx1xJwhtmGSIZrqE5ZWpfHgDaYkI83FEKuIqjtQ8F+YiDHwGtlRGXIJtP10BmqPACyUEnv0i3kcBaeRn3Gg+wl3X8a0i82mMqBu/BU4kbmfAU= 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 1618B1007; Tue, 4 Mar 2025 06:23:43 -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 9B74E3F66E; Tue, 4 Mar 2025 06:23:27 -0800 (PST) From: Hongyan Xia To: Ingo Molnar , Peter Zijlstra , Vincent Guittot , Dietmar Eggemann , Juri Lelli , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider Cc: Morten Rasmussen , Lukasz Luba , Christian Loehle , Pierre Gondois , linux-kernel@vger.kernel.org, Hongyan Xia Subject: [PATCH v2 1/8] Revert "sched/uclamp: Set max_spare_cap_cpu even if max_spare_cap is 0" Date: Tue, 4 Mar 2025 14:23:08 +0000 Message-Id: <4d7dc8f07bede735d307969ca58ed145ff2254eb.1741091349.git.hongyan.xia2@arm.com> 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: quoted-printable Content-Type: text/plain; charset="utf-8" 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 857808da23d8..71fc86eafbd9 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -8417,10 +8417,11 @@ static int find_energy_efficient_cpu(struct task_st= ruct *p, int prev_cpu) for (; pd; pd =3D pd->next) { unsigned long util_min =3D p_util_min, util_max =3D p_util_max; unsigned long cpu_cap, cpu_actual_cap, util; - long prev_spare_cap =3D -1, max_spare_cap =3D -1; + unsigned long cur_delta, max_spare_cap =3D 0; unsigned long rq_util_min, rq_util_max; - unsigned long cur_delta, base_energy; + unsigned long prev_spare_cap =3D 0; int max_spare_cap_cpu =3D -1; + unsigned long base_energy; int fits, max_fits =3D -1; =20 cpumask_and(cpus, perf_domain_span(pd), cpu_online_mask); @@ -8482,7 +8483,7 @@ static int find_energy_efficient_cpu(struct task_stru= ct *p, int prev_cpu) prev_spare_cap =3D cpu_cap; prev_fits =3D fits; } else if ((fits > max_fits) || - ((fits =3D=3D max_fits) && ((long)cpu_cap > max_spare_cap))) { + ((fits =3D=3D max_fits) && (cpu_cap > max_spare_cap))) { /* * Find the CPU with the maximum spare capacity * among the remaining CPUs in the performance @@ -8494,7 +8495,7 @@ static int find_energy_efficient_cpu(struct task_stru= ct *p, int prev_cpu) } } =20 - if (max_spare_cap_cpu < 0 && prev_spare_cap < 0) + if (max_spare_cap_cpu < 0 && prev_spare_cap =3D=3D 0) continue; =20 eenv_pd_busy_time(&eenv, cpus, p); @@ -8502,7 +8503,7 @@ static int find_energy_efficient_cpu(struct task_stru= ct *p, int prev_cpu) base_energy =3D compute_energy(&eenv, pd, cpus, p, -1); =20 /* Evaluate the energy impact of using prev_cpu. */ - if (prev_spare_cap > -1) { + if (prev_spare_cap > 0) { prev_delta =3D compute_energy(&eenv, pd, cpus, p, prev_cpu); /* CPU utilization has changed */ --=20 2.34.1