Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp223790lqp; Tue, 11 Jun 2024 02:32:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXIjxLjZjLb3gD/sAstJfK4tibo19wjuSO2onMtNvtMrMnQBENau6wXLVqRpMy16S8Y2rgyX9wLKhU/dKOd7xx79OIx7JF1WmYzK2mwRg== X-Google-Smtp-Source: AGHT+IEBMOMqyzKFhKagltOPJRk5+aC/HEkeUno2LFWvvPeRUM9vN+GZZpmoDzBsdN77rPC1D+Dv X-Received: by 2002:a17:903:2b0e:b0:1f6:89a0:d14a with SMTP id d9443c01a7336-1f6d02f4e4dmr138737725ad.31.1718098345522; Tue, 11 Jun 2024 02:32:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718098345; cv=pass; d=google.com; s=arc-20160816; b=RAC/A4BHtF9qWVUC7IGeMlfZCQ2df4GQarOT9SShmP14CXXhlFklFiraXlmYViL2bv uQS17fGtMutkYxBM3mKta1dQaNqWGFPYch0bdVEfjKXPuBaAJMK0NqYzIBhfvyQr3EaE PSKwLQsQb8k0guOdBdfSlyT4lgU1dokMeJLKOmBea+2e7ikaGlZBR8HMghHCUw7QeDD5 brWuDPVsPgaBOv5qMc/QckMehIZch88RUIq3532AiWteZoayPWh2JTejCqpULW9muRGo HVWDItfxDOmulAZcRdtVQZwLTLtYKU8xwbNVuo+1dK/5QjPTUxgyQOTIQRga7xliMwke g+fg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=KVVs7pEh5noTOhp7A5IdQmJyy30Z1s9XEBjdu7lfFpY=; fh=Og6kzWSNwOVaSES6IdSkamF9rv9RTxfk1oPj347Bp8g=; b=tcIdSmfgJQaOU8TT2pGF+zmlfamMFiwJsyccAVb/UgTbtdMmID6iJbA3C6GzZ9+N3/ PrcA8GUl4n/uBV5OErJ3958wWJ/tbGo11g2MIvyiP2godr04OXtSOhjZLn9jZnZacBr5 lvz8sf///A8NElOE/N0n/w8ljP3xlYCwtg/uNn2D6x1W/nD363ymC3KxqMotpbbTeL+0 DSeE0HYgl4CdPPnqzLQSx5+XFXk9J03nPIvFAYqW/ZtGX/AS54ElBADpAbLFyvN5BGic 4jo6V8SNZqkBHO4J2b6YlqCrKmyY0zHH3kQzQmpBVixkhh3W2/XRYsv7zJPuGUX/wdDd IUKg==; 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-209542-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209542-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f719561ef9si27676305ad.405.2024.06.11.02.32.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 02:32:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-209542-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; 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-209542-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209542-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id A6343B2625A for ; Tue, 11 Jun 2024 09:08:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6852517624E; Tue, 11 Jun 2024 09:08:37 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 187D3173321 for ; Tue, 11 Jun 2024 09:08:34 +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=1718096916; cv=none; b=rmQeQ/bfmr3mxXTtd5j8m5sNxXFSX0xqmq0ss9yIkADwJfMq1f1YGlj4M1FDzh1wbe8sB/2rSrSkeduJhfqaWsd7fdiPO7006igVsmMVEwswIFAuHION/0m4XR0BlpqlOWyY8aYSLG+o2DueBfcS+vwRIgYQ64ZHMzKrD1zWjv8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718096916; c=relaxed/simple; bh=OVLQFBwi4QgYdNDaYc2IozUgZCW8XhCxwm2z4IDdB44=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=frNH4xlK1h1D33zxwYl+6jjFJ54T0r+qiY7eeXPebWlC6iFyR8uzdAhYJ6fm+NEq1Oq93b00N94h1VdEjTZJiJ5m5yh/376qZ0e5wZzMsUW7YTqeR+gVl+OWOvfJmWA7EPLQih5VtT6sFuVXNBMz2XtdPJ4ngvgXQcGVJ6LWaGM= 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 B79411424; Tue, 11 Jun 2024 02:08:58 -0700 (PDT) Received: from [10.1.32.59] (e127648.arm.com [10.1.32.59]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D16823F5A1; Tue, 11 Jun 2024 02:08:30 -0700 (PDT) Message-ID: <6b909593-ffc2-4fbb-b49a-143ef1fb42d7@arm.com> Date: Tue, 11 Jun 2024 10:08:28 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] sched/fair: Prevent cpu_busy_time from exceeding actual_cpu_capacity To: Xuewen Yan , vincent.guittot@linaro.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, dietmar.eggemann@arm.com Cc: rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, vincent.donnefort@arm.com, qyousef@layalina.io, ke.wang@unisoc.com, xuewen.yan94@gmail.com, linux-kernel@vger.kernel.org References: <20240606070645.3295-1-xuewen.yan@unisoc.com> Content-Language: en-US From: Christian Loehle In-Reply-To: <20240606070645.3295-1-xuewen.yan@unisoc.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 6/6/24 08:06, Xuewen Yan wrote: > Because the effective_cpu_util() would return a util which > maybe bigger than the actual_cpu_capacity, this could cause > the pd_busy_time calculation errors. > So clamp the cpu_busy_time with the eenv->cpu_cap, which is > the actual_cpu_capacity. > > Fixes: 3e8c6c9aac42 ("sched/fair: Remove task_util from effective utilization in feec()") > Signed-off-by: Xuewen Yan > --- > kernel/sched/fair.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 8a5b1ae0aa55..8939d725023a 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -7870,7 +7870,9 @@ static inline void eenv_pd_busy_time(struct energy_env *eenv, > for_each_cpu(cpu, pd_cpus) { > unsigned long util = cpu_util(cpu, p, -1, 0); > > - busy_time += effective_cpu_util(cpu, util, NULL, NULL); > + util = effective_cpu_util(cpu, util, NULL, NULL); > + util = min(eenv->cpu_cap, util); > + busy_time += util; > } > > eenv->pd_busy_time = min(eenv->pd_cap, busy_time); I can reproduce the issue and the fix, so Tested-by: Christian Loehle (@Qais, this is on a non-overutilized system). I'm unsure about the other callers of effective_cpu_util(), or rather sched_cpu_util() in particular which includes thermal and powercap, they should be off too. Anyway I'll try to reproduce for them too. Kind Regards, Christian