From patchwork Thu Feb 1 13:11:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongyan Xia X-Patchwork-Id: 195322 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2719:b0:106:209c:c626 with SMTP id hl25csp138864dyb; Thu, 1 Feb 2024 05:12:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IEbTht/3M02rsezRBHUmOzrg94IzHn+VEeD+XG6qrro2T2TSi9S3H4NKUl+22DkeMY6VQ8g X-Received: by 2002:a0c:f108:0:b0:68c:668d:a671 with SMTP id i8-20020a0cf108000000b0068c668da671mr2369850qvl.7.1706793160930; Thu, 01 Feb 2024 05:12:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706793160; cv=pass; d=google.com; s=arc-20160816; b=kIak6HKCMJnoMRB/zeb2RHfPLu5S/5Qb7hwRP5QtSz13FfIb99lpm2R2JdPQX/medI 9HZHyXrz/alOipsxpuYvsf3pEmDN5LX3yRjhRXKXmbehMFeEkqgdsnSIGolJDioT4bzf mhk5WmIQsE9IV3+yLH4wKENq87AC0nRkO//yhlFzhC3YC8pIkS0hPsn99XVZY3R6tX1v c32hv+XDUyM7zPy0f0NfOMRO1ArRzU6GRQRhK5Ckq3aV5Qu/pq56upwS0Ty5qjs0gknA jq3ibV4alOcONk921HBBcJFZTpccvAWXa1Wi2+Lnhc7tNKg5nCYVRtOaQLNCDh8U2kuw 8cDg== 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=ABmjE1OSvVq1hvAi8ZyAYYefhaBHSNFlyd9DLF0WKv4=; b=nJmk+Vr6mFpowQakCZblYIYNjheFn0jz96aeeahvyNfrnd+48u9xI14/LZWiO51t57 MldYwPh/Ra4yOHclZqJOt+Wd81EISuFn0iipx3PA3AaXsPtvxHH5A8P2wtOAf/68gmh6 hYkpojJ++CWzmuUBPKuc4m7oqHAst0xLkzNkmugmdjk3sLY92s/aQLZ8g1ujBptLOu0h 0RVVaI8TVweRKj1t0W3NhbxbZebdyrGGeYFYu1TQt0uAW0BjzByMuE0JpLoVsvgavyat Icu1fk1+TE3hQTJvW65nlwFIYwoQz3FrEVeQHPRvwd2QI0LVPKvHP0lo9eaqPaCo6WGp SB7A==; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48203-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=1; AJvYcCUXG6cuOjrshPfTblQ5Y8JWF9kheEoTG7oIcByeQLcy0v5vY4d3EMVwqz7W0NSdEmSs3gAL6YK8LihmnJ94C8tLJQPD5w== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id r7-20020ad45767000000b006852fb947b1si14333187qvx.412.2024.02.01.05.12.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 05:12:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48203-ouuuleilei=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-48203-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48203-ouuuleilei=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 B63941C26395 for ; Thu, 1 Feb 2024 13:12:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 884AC5B673; Thu, 1 Feb 2024 13:12:19 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789702345766307738 X-GMAIL-MSGID: 1789702345766307738 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 */