Received: by 2002:a05:7412:8d09:b0:fa:4c10:6cad with SMTP id bj9csp60254rdb; Mon, 15 Jan 2024 12:06:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IHGZnN4fXno7R946u7rDLPCqyXRG4QctLQQ/UW/iyN5QcsGOPIqhKhncSTUPhrx5VazKnMI X-Received: by 2002:ac2:5dc8:0:b0:50e:f4a3:4e78 with SMTP id x8-20020ac25dc8000000b0050ef4a34e78mr1151024lfq.62.1705349177573; Mon, 15 Jan 2024 12:06:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705349177; cv=none; d=google.com; s=arc-20160816; b=tOAWIxQQMFSXHmmf6grmx/jhOdjNEo+LnN+3P8y3Zp9BiaI7FrWhimXFH2HHA2z5OZ klAgKqzF31lkajpdlcZwb27SYuTEOawCXNULsMmofUCIqYZIAeHMHvfSt1br7WuvGiGD JdKd/Em/PuYgs85DGbmHk4TDQT98cmI9GD62QbYg2fVeKOVFS48q6BAMaxH6RAY1z90d Q7S3fvdgkeArFlr3pKfzUQ/iEi893fwQUEFZA+5DTlGoDT9XJQYdnMOqz57yWXOZt28f 4TZGgSl0N133j3C9yr4ug5JWaEF5/sm0W+44eYp7QvTZ/yNN+ZKGZyJ4uqIfuRi6npoG Uv5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=g2J6GrRjkbf4O4Dq3OqrSbIk5tLyX20FE4/kLZUhd+o=; fh=8IcOngKStxaMu46yRIXeE+Qrhos49a43ahIAibcHEgY=; b=F34C2fzgiKGMUqBoqDOFzQKZtTQ8wA7DddYfyI8M+FTwUWF2JqYTMaXkFudgCK+Iqs NruozVckrirL4ufZrK1XgjlGqMximwL4gcfHbJLyGd9zqb0yo6N3Q9GninnlCNwoO1sf F04UuLHTEMoFIfB5nman55n62yIqvU4KbudRXEx+UcM2BHKOGDQLJGVjVMR08Xk1ERSj wevJ5kkAZqum/wE/SeVDerblEKeimiI7sjKHAunpXFOzAn20C9IGV6Sxbn1W7hpc5Uax Wljk0Zj4zASGVYLPa+wea5Nzn+986d9Kixaodr0nNhLApDlNedJbLnc0jqNj7eKvPNa5 tUYw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26460-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26460-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id dt20-20020a170906b79400b00a28fbf42caesi4046703ejb.633.2024.01.15.12.06.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 12:06:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26460-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26460-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26460-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 4EDB01F22D61 for ; Mon, 15 Jan 2024 20:06:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 13D3E19471; Mon, 15 Jan 2024 20:06:09 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CC34418E2A; Mon, 15 Jan 2024 20:06:06 +0000 (UTC) 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 B6BC02F4; Mon, 15 Jan 2024 12:06:52 -0800 (PST) Received: from [192.168.178.6] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9AA713F73F; Mon, 15 Jan 2024 12:06:03 -0800 (PST) Message-ID: <781c567a-5af1-414e-844f-7312dd8b70ff@arm.com> Date: Mon, 15 Jan 2024 21:06:03 +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: Fix frequency selection for non invariant case Content-Language: en-US To: Vincent Guittot , mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, wkarny@gmail.com, torvalds@linux-foundation.org, qyousef@layalina.io, tglx@linutronix.de, rafael@kernel.org, viresh.kumar@linaro.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org References: <20240114183600.135316-1-vincent.guittot@linaro.org> From: Dietmar Eggemann In-Reply-To: <20240114183600.135316-1-vincent.guittot@linaro.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 14/01/2024 19:36, Vincent Guittot wrote: > When frequency invariance is not enabled, get_capacity_ref_freq(policy) > returns the current frequency and the performance margin applied by > map_util_perf(), enabled the utilization to go above the maximum compute > capacity and to select a higher frequency than the current one. > > The performance margin is now applied earlier in the path to take into > account some utilization clampings and we can't get an utilization higher > than the maximum compute capacity. > > We must use a frequency above the current frequency to get a chance to > select a higher OPP when the current one becomes fully used. Apply > the same margin and returns a frequency 25% higher than the current one in > order to switch to the next OPP before we fully use the cpu at the current > one. > > Reported-by: Linus Torvalds > Closes: https://lore.kernel.org/lkml/CAHk-=wgWcYX2oXKtgvNN2LLDXP7kXkbo-xTfumEjmPbjSer2RQ@mail.gmail.com/ > Reported-by: Wyes Karny > Closes: https://lore.kernel.org/lkml/20240114091240.xzdvqk75ifgfj5yx@wyes-pc/ > Fixes: 9c0b4bb7f630 ("sched/cpufreq: Rework schedutil governor performance estimation") > Signed-off-by: Vincent Guittot > Tested-by: Wyes Karny > --- > kernel/sched/cpufreq_schedutil.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c > index 95c3c097083e..d12e95d30e2e 100644 > --- a/kernel/sched/cpufreq_schedutil.c > +++ b/kernel/sched/cpufreq_schedutil.c > @@ -133,7 +133,11 @@ unsigned long get_capacity_ref_freq(struct cpufreq_policy *policy) > if (arch_scale_freq_invariant()) > return policy->cpuinfo.max_freq; > > - return policy->cur; > + /* > + * Apply a 25% margin so that we select a higher frequency than > + * the current one before the CPU is full busy > + */ > + return policy->cur + (policy->cur >> 2); > } > > /** Reviewed-by: Dietmar Eggemann Tested-by: Dietmar Eggemann (on Intel Xeon CPU E5-2690 v2 with frequency invariance disabled)