Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp492210lqh; Tue, 7 May 2024 05:51:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWAKgm2fS5Aa8Oj7yf526FylxpLC/Qfm4Vjhp6eoeMGei5q8hAwuI6lIf2IezWODT+YK4xMuQADVvJryACdNE7hp5LjP9M22Sw0A8+OUA== X-Google-Smtp-Source: AGHT+IF1NzujnkEOoFv6yvRwk74FiAsBh+EOaHFnyJQta2GoFScda2QxKFjdexgdjWVP+4uXZiVO X-Received: by 2002:a05:6830:442b:b0:6f0:616f:f198 with SMTP id q43-20020a056830442b00b006f0616ff198mr6273012otv.3.1715086264380; Tue, 07 May 2024 05:51:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715086264; cv=pass; d=google.com; s=arc-20160816; b=iGlMzMSegW18Te4ZwN23TUBoOzSNQOoKQjoPXwor5lVKU2zIg5sBfKn5NzhH8HU1gl 6qo1kBYBe/NqTmI84HGYVTZ+00eln+o1266PxyN+R2IS0hE7oWWXYzjkfKrGpw9UzZe3 Ee4xvET1js/T5hrd27xPwehTflHXWvf8WKz05huvPX2saNWGrqIgreasEYNHJVbtUsOJ iOaOr9oOahmidM7wT9Ug97F5GOa59tZYm9zUsAkbHumlZntSyhA73v3qniOjzZyzopx6 oGQNpcZJCSdfQWCufzf5AzpNu4qm3Sas1/ZGWR/y4em09oHkRCG1ZOQnJ/SKLpO+MZEb 6Yjg== 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=P9ym+Wm1xodxLb7npdEVLB/TVZfW1Xr00YalABRm3Pk=; fh=JWhVqxGs7G6jn09mcM/L1rTvCtvt8ORzviATBA+M8gw=; b=cNFoVzw9uEDCqqI9pR/W2z2lZomzInjHI1Bxecsp7OTrXRKPuDJtfX4aeBVMbF4yfD ZdA2Bmsboob+wzkrP1IxunOrBb14PF6QXsJ7VqPtHZuioPLL9EwIAbFfKkfKvgk7t3JQ 4oh2G129bba98lpL0xUc8n/TcofmJm90zIlD3qT2ghA/s0vOS1tqpD0k4D1Xi2yTH+Lp wBMGl974wsBqZMbHW4uaEww9j1PJVaaNOAtalpnX4exdwN+K2aKtoRPlJ7K8Ivq+6ZsX /VfbLmudQTI3BIUO8O1ZvIytoNApfj7nTQaVc2nmyKTzTQdPvPVbMrQFH6RGyYlEvMR8 Sj4w==; 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-171310-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171310-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v21-20020a05620a441500b0078ecb975c13si12555771qkp.253.2024.05.07.05.51.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 05:51:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-171310-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; 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-171310-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171310-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 077001C215FB for ; Tue, 7 May 2024 12:51:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2E1DE15D5DB; Tue, 7 May 2024 12:50:47 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C9B7915B98F for ; Tue, 7 May 2024 12:50:44 +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=1715086246; cv=none; b=B3Cx5Rzyrfe8ydrgievjVO74O957fDLN9iaP7e8fKoilmRludsSajIuM5OnOz8xjI+Jt1GMqwSFomobT1HMqYwYP/cpKpyqXQEWueTz2DXO2mQQvApc4v4/8oPdl9FvBdBj2I5RqDVH1oPLfj2op6nf0X4qsuM2++kYeZcQZprw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715086246; c=relaxed/simple; bh=x1+k2VVwyMidazrUOXCE1ixNy96bzakjLfcXmD4JUA4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DlF7EBHxZIRnuo9qVsPYS/CmTy6Ft8Ji4+N2UFEvBWrIgyGEeS88tMNfDNP4KQ1NnwFnXoO7s5XlUJLQFr2zbEPdklkudqLwopQUhOgyqHT8LixmDLtNEKYQj9zlqlQaitWSyhbVeLCZvswZ9+u/MCA2vDQ3wEq4K1it/UGzwdk= 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 D8BDC106F; Tue, 7 May 2024 05:51:09 -0700 (PDT) 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 BC1DC3F793; Tue, 7 May 2024 05:50:41 -0700 (PDT) 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 , pierre.gondois@arm.com, linux-kernel@vger.kernel.org, Hongyan Xia , Hongyan Xia Subject: [RFC PATCH v3 1/6] Revert "sched/uclamp: Set max_spare_cap_cpu even if max_spare_cap is 0" Date: Tue, 7 May 2024 13:50:24 +0100 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 9eb63573110c..ef5bb576ac65 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -8022,10 +8022,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_actual_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); @@ -8087,7 +8088,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 @@ -8099,7 +8100,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); @@ -8107,7 +8108,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